aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Specifying  the location of db.db 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 "Specifying  the location of db.db" Watch "Specifying  the location of db.db" New topic
Author

Specifying the location of db.db

Lance Finney
Ranch Hand

Joined: Apr 26, 2001
Posts: 133
How are people specifying the location of the local db.db? I'm hesitant to hard code the location, so I want to use a properties file. I've had success with this approach running my app from an IDE and from the command line, but not from within an executable jar.
Should I just not bother and hard code the location, or should I not expect the user to use an executable jar?
Thanks
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
You are allowed to pass the db name as the command line configuration parameter.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Or you could hard code it from the standpoitn of relative path. Either in the same DIR as the executable jar, or a subdirectory of it.
Look at System.getProperty("user.dir")
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Pallav Grigo
Greenhorn

Joined: Mar 29, 2002
Posts: 29
Hi..I don't think you need to speify any relative path..please correct me if i'm wrong..but when you call new File("db.db")..doesn't the JVM look in the current directory?? So what's the point of System.getProperty("user.dir")?...I'm not sure about this..so all reponses will be of great help!!
Pallav
Lance Finney
Ranch Hand

Joined: Apr 26, 2001
Posts: 133
Originally posted by Mark Spritzler:
Or you could hard code it from the standpoitn of relative path. Either in the same DIR as the executable jar, or a subdirectory of it.
Look at System.getProperty("user.dir")
Mark

So, you suggest extracting db.db in the same directory as the exectuable jar. I guess that would work. For some reason, I was thinking that I would want to keep db.db within the jar, but I guess that wouldn't work.
Interesting.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Hey, I just took the easy route. Why add complexity when it isn't necessary? That's my motto.
I did not lose any points for it.
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Specifying the location of db.db