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?

1
  • 1
    Add logging statements to your code. Commented Jul 26, 2013 at 21:01

3 Answers 3

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 
Sign up to request clarification or add additional context in comments.

1 Comment

Just tried that and got the response listed above in my question.
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.

Comments

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.