Java program only works on the development machine

Asked

Viewed 2,086 times

1

I created a Java application in Netbeans. This application has a GUI and uses some external Jars.

After doing Clean and Build in the Netbeans dist folder a Jar (main class) and a folder named lib (which has the external Jars I use) appeared. When running the Jar (main class) that is in the dist folder everything works normally. I checked the Class-Path and everything is OK. I even changed the name of the folder where the libs are and the program stopped giving, which means that the Jars in the lib folder are being used and not others.

The problem is that when copying the dist folder (which has the main class and the external Jars) to another computer (with the same version of Java installed) the program does not work.

Someone can help me?

  • 1

    Some jar is missing. To know which one I suggest you invoke your executable jar by cmd, so it will be possible to see which exception is being launched, because when it gives two clicks you have no feedback, correct?

  • If the dependencies are in a subdirectory, it means that when running Jar this directory must be being informed in some way to the JVM. Which classpath did you check? If it’s netbeans, it won’t be the same when the jar runs outside of that environment. Or maybe it is set to absolute instead of relative path. It would be interesting to post more information about your configuration.

  • Any error message? What is "program does not work"?

  • 1

    @Math One of the Jars used an auxiliary file that was missing...when I saw on the console I realized what the file was. Thanks.

  • @utluiz The class path I checked was the main jar

  • @Caffé program when booting used one of the auxiliary jars (lib) and this one used an auxiliary file that was not present.

  • @Joãofonseca So you’ve solved the problem?

Show 2 more comments

1 answer

6


When nothing happens while trying to open the program, it is because it launched an exception before even loading the graphical part, so no error is shown to the user.

To be able to see what is the exception that is being launched you can run your jar through the command prompt or terminal, because it will launch the exception that is occurring and then you will get the explanation of your problem, so it will be easy to tidy up your project.

To invoke it via command line use the following command:

java -jar nomedojar.jar

In your case, it is very likely that some dependency is missing as the program works correctly on your computer and apparently the other one’s configuration is ok, so you said. With the exception hint at the prompt, add the missing jar to your project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.