aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Several questions about SCJD instructions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Several questions about SCJD instructions" Watch "Several questions about SCJD instructions" New topic
Author

Several questions about SCJD instructions

jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
I'd thank Andrew first.
I almost complete my assignment. I am testing and checking the code, and preparing for packing my project. I read the SCJD instrutions again and again, while I still can not understand it well.
-----------------------------------------------------------------
Q1: " All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes. All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII. "
I use RandomAccessFile class to read and write value. Must I use the DataInputStream and DataOutputStream classes??
-----------------------------------------------------------------
Q2: " Your choice of RMI or serialized objects will not affect your grade, but no other approach is acceptable. In either case, the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely. No authentication is required for database access. "
" When you submit your assignment, each part (client and server) must be executable using a command of this exact form:
java -jar <path_and_filename> [<mode>] "
" Your programs must not require use of command line arguments other than the single mode flag, which must be supported. The mode flag must be either 'server', indicating the server program must run, 'alone', indicating standalone mode, or left out entirely, in which case the network client and gui must run "
" The executable JAR containing the programs. This must be called runme.jar. "
According my understanding about upper words, I wrote only one main class to start programs with defferent commands:
To start client program: java -jar runme.jar alone
To start server program: java -jar runme.jar server db.db
Am I right??
-----------------------------------------------------------------
English is not my mother tongue, I just want to make it sure.
I still have other questions, I will post them next time.
Thank you all!!
Arun Kumar
Ranch Hand

Joined: Aug 29, 2003
Posts: 67
I can say something about Q1. I havent reached the server part yet. So i cannot comment on Q2.
About Q1, The instruction just lets you know that the numeric primitive datatypes are in binary format. So you can use RandomAccessFile or DataInputStream to read the numerical part.
Atleast i am using RandomAccessFile for that.


SCJP (1.4), SCWCD, SCJD
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
Q2 continue
I read the following sentence again and again:
"The mode flag must be either 'server', indicating the server program must run, 'alone', indicating standalone mode, or left out entirely, in which case the network client and gui must run "
mode = server, than run server program ;
mode = alone, than run client program ;
If no mode or (mode != server && mode != alone ) , run client program still
Is that so??
"in which case..." is which case, "left out entirely" case??
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

Hi Jhao,
[Instructions] Your programs must not require use of command line arguments other than the single mode flag
[Jhao] To start server program: java -jar runme.jar server db.db

According to the instructions you listed, you are not allowed to have anything else on the command line apart from the mode flag ('alone' or 'server'). So you cannot put the 'db.db' on the command line.
"in which case..." is which case, "left out entirely" case?

left out entirely = no mode
That is, if there is no mode given on the command line, then you run the network client and gui.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
Thanks Arun Kumar and Andrew Monkhouse !
Andrew, you think there is only one parameter: mode or no parameter. Only two cases, because the Instructions says
[Your programs must not require use of command line arguments other than the single mode flag, which must be supported] .
While see this
[Your choice of RMI or serialized objects will not affect your grade, but no other approach is acceptable. In either case, the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely. ]
This really confuse me !
Please help me
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

Hi Jhao,
Only the following options are possible:

Do you see how with only two options, we have 3 cases?
The first case will start the GUI client in networked mode.
The second case will start the server.
The third case will start the GUI client with no network.
the program must allow the user to specify the location of the database

You have to be able to specify the location of the database, but you are not allowed to do it on the command line. Solution: dialog box or separate screen for entry of this information.
Regards, Andrew
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
What I most worry about is automatic failure. It seems that I don't understand the sun instructions very well.
Thank you very munch, Andrew. You have helped me greatly.
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
Q3. "Your programs must not require use of command line property specifications. All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory. "
To solve the Q2, I show a input dialog box to let user enter the db file name or remote server URL address. According the Q3, I should store what user entered(db file name/URL address) into the file: suncertify.properties. And the keys are decided by me. Is that so??
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

Hi Jhao
Correct.
Regards, Andrew
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
Q4: In sun instructions.html:
"1 byte flag. 00 implies valid record, 0xFF implies deleted record"
0xFF==255, 1 byte is -128~127, java seems no unsigned type
how to understand this.
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi jhao,
(byte) 0xFF == (byte) -1
Best,
Phil.
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
Thank you,Philippe
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
Q5:
"Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package. Each must have a zero argument constructor and a second constructor that takes a String that serves as the exception's description. "
This interface called "DBAccess" is provided by SUN in which there are some exceptions.
I created 'RecordNotFoundException','DuplicateKeyException' .......in suncertify.db package except the 'SecurityException'.
Because the 'SecurityException' exists in java.lang package, it seems that I need not create it. Must I create it in the suncertify.db package??
Today I found a fatal error and solved it. When a record is locked by anthoer customer, the thread which also wants to lock the record did not wait for it released, just throw exception and exit.
I modified the lock method, and it runs well.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

Hi Jhao,
It is such a nice feeling when you find a bug and fix it
Doing a search on "SecurityException java.lang" found me this thread - you may get some ideas there.
Could I suggest that when you have a new question to ask which is unrelated to the existing questions in a thread, that you should open a new topic for it (with a suitable subject line)?
By reusing this thread, you run the risk that people will not see your latest question. They could open this topic, see that the first post is asking about which class to use to open the file and how to start the applications from the command line, and so they might decide to skip the remainder of the topic.
Regards, Andrew
jhao wang
Greenhorn

Joined: Aug 31, 2003
Posts: 15
Thank you,Andrew.
I accept your suggestion.

Reading the thead you provided, I decide not to create the 'suncertify.db.SecurityException' either, but I still catch it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Several questions about SCJD instructions