Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

[SOLVED] Program runs properly in IDE but not as jar

Typically my java programs are either for personal use or for school so I always just run them in eclipse. The program I am currently working on I plan to release here on HF so I decided to figure out how to export it to a jar... first time doing so. When I run my program in eclipse everything works as it should. When I run the exported jar the program doesn't work properly. It goes through the first few steps of main and then ends.

--> Yes the jar is associated properly, it runs.
--> Main is set in the manifest.
--> No exceptions are thrown.
--> Consists of a main, 1 class, 4 images, and a bunch of imported java classes.

--> From various tests through command prompt it seems the issue lies either with the images or with the second class. So what can be the problem here I'm pretty stumped and I've seen a lot of people with this problem online and none have a solution for me.
I've had this issue before, the issue is due to how resources are located in debug mode in an IDE when compared to running the jar outside the IDE.

How do you reference your paths? Try adding a prepending "/" before the string location. Works for it. Or try prepending "file:"

I've never really understood why the error occured, but trial and error helped me fix it. Anyway, show the part of your code you're having issues with.
Are you sure you export any libraries into the jar and put in all other resources?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by Tr0jandogOct 11, 2019 08:32 PM 1 201 Oct 11, 2019 08:32 PM
Last Post: stderr
[C#] by ElectronJan 14, 2018 04:02 PM 0 131 Jan 14, 2018 04:02 PM
Last Post: Electron
[C#] by waflya.waflyDec 18, 2017 05:06 PM 1 215 Dec 18, 2017 05:06 PM
Last Post: itcorp