• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access files outside jar file

 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your suggestion please.
1.when run java -jar client.jar db.db. Exception was thrown.
2.when I access remote server by run client.jar and try to show online help but client.jar can not find userguide.html.
I put client.jar, db.db, userguide.html in the same dir starting\,
summary: I can not access files outside client.jar.
thanks in advance
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider this. a jar file is the start of a path. The files that are inside the jar file have further path information. When you run the jar file with java -jar client.jar you are telling java that you have a manifest file in there that will point to the main class. However, you have not told java the classpath. This is really important to access outside files. Becuase java still needs to know where to find them, and it looks in the classpath, if the classpath is not set, and the files aren't where the classpath is set, then you will get your error.
What is your classpath?
Mark
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. got your idea.
somebody's online.html is put in a dir. starting\doc\online.html. the classpath is set at starting\. when I put file in classpath I can access them. but if I put them in a dir which in the classpath I don't know how to access them. could you give me some idea please
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic