This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Access files outside jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Access files outside jar file" Watch "Access files outside jar file" New topic
Author

Access files outside jar file

Dasong
Ranch Hand

Joined: Apr 05, 2002
Posts: 36
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Dasong
Ranch Hand

Joined: Apr 05, 2002
Posts: 36
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
 
jQuery in Action, 2nd edition
 
subject: Access files outside jar file
 
Similar Threads
server.jar can NOT find _stub, help!
About packaging
Packaging
exception while reading db.db file from jar file
Jar file for the codebase