• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Access files outside jar file

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic