| 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
|
|
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
|
|
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.
|
 |
 |
|
|
subject: EXE JAR shows FileNotFound Exception, runs fine on netbeans
|
|
|