Win a copy of Java Challengers this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

JAR FileNotFoundException

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I thought I was close to getting this JAR program working but now im completely confused again!

My program tries to access an XML file but i get a FileNotFoundException error saying that there is no such file. However, the error prints out the correct path to the file! the file exists, its in the JAR, it has the correct path but i am still getting this exception.

any ideas?

Ben
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
little to go on...

If the file is in the jar you need to have the jar on your classpath and refer to the file using the path inside the jar, not the path to the jar.
 
Ben Wong
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen T Wenting:

If the file is in the jar you need to have the jar on your classpath and refer to the file using the path inside the jar, not the path to the jar.



I get what you're saying..but how do include the jar in the classpath?
at the moment this is how i am setting the classpath:



The above parsing code works fine when running in Eclipse. but the jar will say that the file is not found.

The path that is printed out when the exception is caught is the correct path that includes the jar file:



mak1.jar is the name of the jar file. i dont know what the exclamaition mark is but i dont think it causes any problems.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic