aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
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: 2289
    
  49
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: 2289
    
  49
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://aspose.com/file-tools
 
subject: EXE JAR shows FileNotFound Exception, runs fine on netbeans