简体   繁体   中英

Double click won't start executable jar

I ran into a strange issue.When double click an executable jar it won't open however if I do the following it starts without a problem:

java -jar working_neon.jar

This jar is a swing gui application.The jar file creation is done by eclipse Here is the manifest file:

Manifest-Version: 1.0
Rsrc-Class-Path: ./ miglayout15-swing.jar Message.jar org.apache.commo
 ns.io.jar
Class-Path: .
Rsrc-Main-Class: gui.FileCopyManager
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

Any ideas?

If you are using eclipse: Go to File->Export, under Java folder select 'Runnable JAR file', under Launch configuration select the class where your main method is. Select the export destination, then select Library handling to 'Package required libraries into generated JAR', and click on finish. This works for my swing gui app. I hope it helps

Finally managed to fix my problem by selecting Extract required libraries into generated jar when creating a jar file from eclipse

在此处输入图片说明

Make sure that you don't use a higher Java-version in Eclipse Project-settings / Run-Configuration than the JRE used to run the jar .

In Eclipse right-click you project -> Properties -> Java-Build-Path -> Libraries.

There you will see the JRE-Version that will be required to run the jar. (Also check the JRE-Version set in Run-Configuration)

Open commandline and type

java -version

Make sure the version displayed there is at least as high, as the one you found in Build-Path and Run-Configuration!

If the version displayed is not as high as the version in build-path either decrease the JRE-version set in Eclipse Build-Path/Run-Configuration or - if not possible - change your PATH-variable to use a higher versioned JRE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM