This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes EXE JAR shows FileNotFound Exception, runs fine on netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "EXE JAR shows FileNotFound Exception, runs fine on netbeans" Watch "EXE JAR shows FileNotFound Exception, runs fine on netbeans" New topic
Author

EXE JAR shows FileNotFound Exception, runs fine on netbeans

rohan sethi
Ranch Hand

Joined: Dec 14, 2012
Posts: 34

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?
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 1225
    
    3
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

Joined: Dec 14, 2012
Posts: 34

Ahh solved it.Just was a simple problem.Need to use a "\" in getResource() .To show it's not a directory.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 1225
    
    3
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: EXE JAR shows FileNotFound Exception, runs fine on netbeans
 
Similar Threads
2GB file returning 0 length
how to update a property file?
Exporting .jasper files with NetBeans
FileNotFoundException in wired situation
Running a .exe from java program