Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Specifying the location of db.db

 
Lance Finney
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are allowed to pass the db name as the command line configuration parameter.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pallav Grigo
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic