简体   繁体   English

如何通过双击从Eclipse运行导出的.jar?

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

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. 我为Eclipse中的我的项目导出了一个可运行的.jar文件,但似乎无法双击执行它。 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. 从命令行使用“ java -jar program.jar”运行它可以正常工作,尽管我可以留下一个批处理文件来运行它,但是这样做很烦人。 And double clicking some older jars that i've exported from Eclipse works fine. 双击我从Eclipse导出的一些较旧的jar效果很好。 Anyone know how to fix this? 有人知道怎么修这个东西吗? I'm running windows 7 x64 btw(But i have 32-bit java) 我正在运行Windows 7 x64 btw(但是我有32位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. 这是我在32位Eclipse中使用64位Java的问题,而我可能已使用了解决方法。 Once I changed to 32 bit java, everything was fixed. 一旦我更改为32位Java,一切都已修复。

On a Windows system, you will need to convert your .jar to an .exe file. 在Windows系统上,您需要将.jar转换为.exe文件。

Please see How can I convert my Java program to an .exe file? 请参阅如何将Java程序转换为.exe文件? for a good number of alternatives. 有很多选择。

You can change this by setting javaw.exe to execute jar files. 您可以通过将javaw.exe设置为执行jar文件来更改此设置。

My Computer > Tools > Folder Options > File Types 我的电脑>工具>文件夹选项>文件类型

Find JAR in the list and change its 'opens with'. 在列表中找到JAR并更改其“打开方式”。

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/ 如果它是Swing应用程序,但仍然无法双击运行,则应尝试使用http://launch4j.sourceforge.net/将其包装为exe文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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