Reputation: 49
I've created a program using Eclipse
and exported as an executable jar
(I've tried all 3 library handling options). It runs perfectly on the computer it was written and exported on, but when I try and run it on other machines it does nothing at all. It brings up no errors, nothing at all. I've got several people to try it for my with no luck, and I've tried running it on my laptop (ensuring that Java is the latest version, the same as the machine that it was written on). The MANIFEST
file points to the Main class correctly.
Does anyone know how I can solve this issue?
It's incredibly frustrating! If any more info is needed, I can supply it.
Upvotes: 4
Views: 11833
Reputation: 25
I got this problem several times. The issue was the jar file runs on the computer where I have packaged. But in another computer it is not running, some time it shows running if I check the javaw.exe process in cmd but nothing is served. The solution here is to make sure the following are set correctly.
For me it worked after changing the java version in the pom file to the oddest ie.the second computer use java 16 then packaged jar file to use java 11.
Upvotes: 0
Reputation: 49
Sorry for the late reply. Thanks for all your answers, but it turned out there was an error in my code that simply stopped it running without showing any errors.
Upvotes: 0
Reputation: 1973
You need to install a Java Runtime Environment (JRE) first, then you can directly run the .jar
files on your computer. The Java Development Kit (JDK) download package contains it's corresponding JRE, so that's fine to install too.
Upvotes: 0
Reputation: 13
When the Java Runtime Environment (JRE) is not installed, the JAR won't be open and won't show you any message. Try installing JRE into the other computer and try again.
Upvotes: 1
Reputation: 1910
That happened to me a lot of times when I started writing java distributed applications.
Check your project build path (since you're using eclipse, right-button click on your project's folder, then Build Path > Configure Build Path). If any of the paths that are specified there are custom *ie C:\User\daMachineMaster\Java\jre\bin
or whatever, it won't work on any other machine because the application will always look for that path, which won't exist in no other machine than daMachineMaster
's computer. You could use a wrapper to fix this issue, since it encapsulates all needed information in a .exe, for example.
If that still isn't your issue, search your code for any links to your local directories. For example,
String style = main.screens.ScreenFramework.class.getResource("C:\Users\Dwayne\Music\cool\DarkTheme.css");
After you've located these kinds of hard links, the solution is changing them to be relative links. Check How to define a relative path in java
In the above case, it would mean changing to something like:
String style = main.screens.ScreenFramework.class.getResource("DarkTheme.css").toExternalForm();
Also, as mentioned in other answers, check if the other computers hava java installed. I don't think that they need any environment variables defined to run a runnable jar but if you want to run your app in the cmdline with something like java -jar yourapp.jar
then you need to go to the windows explorer (assuming you're using windows), right-click Computer, then click Advanced System Settings > Environment Variables > New... > Variable Name = JAVA_HOME; Variable Value = directory where java is installed > OK > Click on PATH > Edit... > add JAVA_HOME\bin to PATH > OK
Upvotes: 3