How do you run exported .jar from Eclipse with double click?

走远了吗. 提交于 2019-12-11 23:13:12

问题


I exported a runnable .jar file for a project of mine in Eclipse, but I can't seem to execute it with a double click. Running it from the command line with "java -jar program.jar" works fine, and while I could just leave a batch file to run it, it is rather annoying to do so. And double clicking some older jars that i've exported from Eclipse works fine. Anyone know how to fix this? I'm running windows 7 x64 btw(But i have 32-bit java)

EDIT: Ignore this question completely. It was a problem of me using 64 bit java in 32 bit eclipse, and the workarounds i may have used. Once I changed to 32 bit java, everything was fixed.


回答1:


If it's a console application then it probably won't open the command prompt on double click although the app may be running in the background. I recommend making batch files for console applications.

If its a Swing application and still won't run on double click you should try wrapping as an exe file using this http://launch4j.sourceforge.net/




回答2:


On a Windows system, you will need to convert your .jar to an .exe file.

Please see How can I convert my Java program to an .exe file? for a good number of alternatives.




回答3:


You can change this by setting javaw.exe to execute jar files.

My Computer > Tools > Folder Options > File Types

Find JAR in the list and change its 'opens with'.



来源:https://stackoverflow.com/questions/6414257/how-do-you-run-exported-jar-from-eclipse-with-double-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!