1

I recently finished a project which works as it is supposed to in my Eclipse IDE as both multiple files and as a single file.

Eclipse exports the jar file and only makes noise about the warnings.

When I go to run the jar file with a double-click, the cursor seems to flash to a hourglass for less than a second and then nothing. When I try to run the jar file from the command line with java -jar myJarFile.jar the command prompt window seems to wait a second and then brings the file path line and cursor with no errors and no other messages.

I have double checked both my Path variable and that I have the latest version of Java installed.

Any suggestions?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Jon
  • 41
  • 1
  • 4

3 Answers3

0

Check this thread: Failing to execute the jar file using java -jar command

Basically, what you need to do is when you run the jar, you need to specify the class to be executed in the command line, like so:

java -cp test.jar com.app.ClassName
Community
  • 1
  • 1
amb110395
  • 1,545
  • 13
  • 16
0

Did you just make a jar file, or a runnable jar file? If you only did the former then it will not execute on a double click. So it's Right Click the project in Eclipse -> Export -> Runnable JAR File -> Choose the appropriate Launch Configuration -> Choose where you want it to go.

0

Confirm that your application code is in the jar file:

jar tf myJarFile.jar

Confirm that your application's main class is listed in the Main-Class attribute in the manifest, and that any other jar files needed by your application are listed in the Class-Path attribute:

jar xf myJarFile.jar META-INF/MANIFEST.MF
cat META-INF/MANIFEST.MF

Try running with verbose logging of classes being loaded; this should show if some necessary class can't be found:

java -verbose:class -jar myJarFile.jar
Matt McHenry
  • 20,009
  • 8
  • 65
  • 64