• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

path of db.db

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just want to know if we can put db.db under a specific directory (say, under classes, for example), and hardcode the path of db.db? How to make it work on different platforms--"/" vs. "\" issue?
Thanks a lot!
Cathy
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Cathy Young:
How to make it work on different platforms--"/" vs. "\" issue?


Here are two very useful commands that you might find handy...
System.getProperty("user.dir")
System.getProperty("file.separator")
The first gives the working directory and the second gives a OS specific file separator.
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Cathy Young:
I just want to know if we can put db.db under a specific directory (say, under classes, for example), and hardcode the path of db.db?


About your first question... I did that but also provided a command line option for the path just in case Sun wanted to point to another db for grading purposes. I cant remember if that is a requirement.
 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nate Johnson:

Here are two very useful commands that you might find handy...
System.getProperty("user.dir")
System.getProperty("file.separator")
The first gives the working directory and the second gives a OS specific file separator.


So, in my understanding, I can use System.getProperty("user.dir") to get the current working path, and append something like
"classes" + System.getProperty("file.separator") + "db.db"
to it. Is this right?
Is this considered "hardcode" which I have always been hesitating to use.
Thanks!
Cathy
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is basically what I did if the user did not supply a path on the command line... I also moved the db to the root of the project because that made it even easier to find
 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nate Johnson:

About your first question... I did that but also provided a command line option for the path just in case Sun wanted to point to another db for grading purposes. I cant remember if that is a requirement.


This sounds a good idea. But I am curious to know how you check if the user input the path of the file. What I want to do is allow for 0 or 1 input args. If there is no args, it is local mode, and the database file is as specified in the source, but if it has 1 arg, how to check if it is filename or hostname? I do not think deliminator is good enough to test.
Thanks!
Cathy
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Cathy Young:

This sounds a good idea. But I am curious to know how you check if the user input the path of the file. What I want to do is allow for 0 or 1 input args. If there is no args, it is local mode, and the database file is as specified in the source, but if it has 1 arg, how to check if it is filename or hostname? I do not think deliminator is good enough to test.


Well what I did was to have prefixes to all of my args on the command line... so my command line looked like this...
java -jar client.jar -fc:\scjd\db.db
or
java -jar client.jar -u127.0.0.1 -p12345
[ August 29, 2002: Message edited by: Nate Johnson ]
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cathy,
I used good ol' Unix style command line flags to do exactly what you want to do. Here's my command line for the client:

Bracketed parameters are optional. So if the "-f" is in the command line, you know its a file instead of a host.
Hope this helps,
Michael Morris
 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nate Johnson:

Well what I did was to have prefixes to all of my args on the command line... so my command line looked like this...
java -jar client.jar -fc:\scjd\db.db
or
java -jar client.jar -u127.0.0.1 -p12345
[ August 29, 2002: Message edited by: Nate Johnson ]



Thanks, this helps a lot! BTW, just curious, is -p12345 port number? Can't we just use the default port number for RMI?
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Cathy Young:


Thanks, this helps a lot! BTW, just curious, is -p12345 port number? Can't we just use the default port number for RMI?


Yep that is the port number... I gave them the option to use any port (above 1024 that is)....
 
Cathy Young
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Michael and Nate! I am still wondering if we need to give the option of not using default port number if using RMI (of course, port number is needed for socket connection).
Thanks!
Cathy
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can I ask the user to supply the command line arguments in a simple dialog instead during program startup instead of supply them in the
command prompt
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Can I ask the user to supply the command line arguments in a simple dialog instead during program startup instead of supply them in the
command prompt


Sure thing. It's your ball and bat, you can make the rules.
Michael Morris
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by CyJenny Wong:
Hi,
Can I ask the user to supply the command line arguments in a simple dialog instead during program startup instead of supply them in the
command prompt


I did both actually... and if they supplied command line args, they were filled in to the gui to be confirmed or changed.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
code:
--------------------------------------------------------------------------------
Local mode:java -jar FBNClient.jar [-f dbFile]Remote mode:java -jar FBNClient.jar host [port]
--------------------------------------------------------------------------------
Is it good idea to provide System Properties on client side command line? for instance:
java -jar FBNClient.jar -DdbFileName="db.db" -DhostName="localhost" -DportNumber="1099"
in such way that number and order of parameters on the command line are not significant.
Thanks,
Patrick
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Patrick Li:

Is it good idea to provide System Properties on client side command line? for instance:
java -jar FBNClient.jar -DdbFileName="db.db" -DhostName="localhost" -DportNumber="1099"
in such way that number and order of parameters on the command line are not significant.


that is why i prefix them... then order does not matter, at least for my solution
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Patrick,
I suppose you could do it that way albeit somewhat cumbersome. You're risking a lot of user "wrath" and hate mail due to the inevitable mis-typing of the command line with such a scheme. So, I would say it's legal to use all command line properties but probably not adviseable.
Hope this helps,
Michael Morris
 
reply
    Bookmark Topic Watch Topic
  • New Topic