• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to access the db.db file stored in jar file???

 
Reshma Das
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a jar file for this appln. while running the
appln if give a relative path like
jar -jar server.jar lib\db.db
It gives the following error :
java.io.IOException: Data: request to open
non-existant or inaccessible file lib\db.db
but if i give the entire path the appln works fine. Do i have to use the db file jared with my jar file or i should give the absolute path for the file pointing to a file located on disk ?
pls respond.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I dont think you need to add the db.db to either client.jar or server.jar
2. The examiner will specify the entire path of file in my understanding. It would be better to specify that the entire path must be specefied while running the program.
Good luck
 
Reshma Das
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really want to access a resource from a jar file you write something like this:
URL url = MyClass.class.getResource("resourceName");
You can then use url.openStream() to read the data.
Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic