• 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

EXE JAR shows FileNotFound Exception, runs fine on netbeans

 
Ranch Hand
Posts: 34
Netbeans IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Creating a swing GUI application, and when run through an exe file, it throws FileNotFound Exception.
The path in my actual code is by using getClass().getResourceAsStream().I think here is some problem..
Runs fine on NetBeans, but fails to do so when converted to .exe file.
What should i do to overcome FileNotFound Exception?
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Creating a swing GUI application, and when run through an exe file, it throws FileNotFound Exception.


How are you converting the app to a .exe? or do you mean you are packaging it in a jar file?

The path in my actual code is by using getClass().getResourceAsStream().


The file needs to be located on the classpath of the object's classloader. What file path are you passing into the method
 
rohan sethi
Ranch Hand
Posts: 34
Netbeans IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh solved it.Just was a simple problem.Need to use a "\" in getResource() .To show it's not a directory.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rohan sethi wrote:Need to use a "\" in getResource() .To show it's not a directory.


That doesn't mean the name is not a directory. If you don't start the name with a slash then the given path of the resource to load is relative to the package of the class.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic