This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
please let me know what u think of the bold text... thanks ^_^ and good day ... ================================================= 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. ================================================ i have used the System.getProperties("user.dir"); is depend to the user, wherether which working dir they are in. SO am i in the right track??
must is must. Not much for interpretation there. hi , 1 .when the assignment mentions database(pls ref. the bold text above), does it mean the location of the db-2x2.db? 2.i am using System.getProperties("user.dir") to determine the working directory so that Data.java will read it from the working directory. 3. if user start the application in workingDirectory(db-2x2.db is in here) with
java -jar app.jar ---> then it will work but it user start the application java -jar ../app.jar or java -jar /whateverpath/app.jar then it will fail.. please let me know how should i fix it...
Joined: May 03, 2003
hi mark please ignore the above reply i just read on the reply that u post to Rag Srinivasan ... i guess i need to add some extra functional in GUI to allow user to choose the file part. Just to confirm, is the file path need to be include in suncertify.properties ?
If you are having a GUI screen that allows the user to enter things like mode, db.db file location, host and port, then it would be nice to save all that information in the properties file, so that when the user runs it again it remembers their last input values. I think in the new assignment they are specifically looking for this functionality. Mark
Joined: May 03, 2003
hi thanks for reply , please let me know if i am in the right track ================================================= db.db file location, host and port, then it would be nice to save all that information in the properties file ================================================= 1. java -jar runme.jar alone --> local mode Using JFileChooser to select the db.db location and save into suncertify.properties 2. java -jar runme.jar server --> server get the port,host,db.db location save into suncertify.properties (is there any API, that i can use for getting a list of port and host? where is suncertify.properties sit, in the jar or user need to select the file from JFileChooser) 3. java -jar runme.jar -->network client and gui retrive from suncertify.properties (do i need to start the server in here/or just assume is started by No.2?) thanks alot .... much much Appreciated !!!
1. java -jar runme.jar alone --> local mode Using JFileChooser to select the db.db location and save into suncertify.properties
Looks good. I went a step further and checked if db.db was in the working directory, and if so, offerred it as a default.
2. java -jar runme.jar server --> server get the port,host,db.db location save into suncertify.properties (is there any API, that i can use for getting a list of port and host?
I do not think that there is any way to get a list of available ports / hosts programattically. To try and find a currently running registry would require some sort of port scanning. To try and find "any available port to start my own registry" would be very easy, but would cause havoc for the users "gee, what port is the server on today ). And trying to find all the local hosts on the local subnet might not be possible, especially if the system administrator has deliberately turned off all services that would indicate what the server is / where it is (I have worked in companies where that happens: if you dont know the hostname and port you need to use, you wont even know the computer exists). A better (IMHO) option is to just go with the defaults (hostname = localhost, port number is the "well known" port number for RMI), then allow the user to override them if they want to.
where is suncertify.properties sit, in the jar or user need to select the file from JFileChooser)
My properties file did not exist until after the user attempted to run the application, after which it was created in the current working directory. On subsequent runs, if there was a properties file in the current working directory then my app used it. You could store it in the jar file, but I think this is going to be far too much hard work for no real benefit.
3. java -jar runme.jar -->network client and gui retrive from suncertify.properties (do i need to start the server in here/or just assume is started by No.2?)
Your choice, but document the choice Personally, I think that starting the server from the client is wrong - what happens if someone decides to shutdown the client, not realising that it has also started the server and there are other clients attached? Sure, you can put up dialog boxes warning the user that this could cause problems, but to me, the client and server should be distinct applications. Regards, Andrew