我有一个名为helloworld.jar的JAR文件。 为了运行它,我在命令行窗口中执行以下命令:
java -jar helloworld.jar
这工作得很好,但我如何执行它与双击? 我需要安装什么软件吗?
我有一个名为helloworld.jar的JAR文件。 为了运行它,我在命令行窗口中执行以下命令:
java -jar helloworld.jar
这工作得很好,但我如何执行它与双击? 我需要安装什么软件吗?
当前回答
最简单的方法可能是升级或重新安装Java运行时环境(JRE)。
或:
Open the Windows Explorer, from the Tools select 'Folder Options...' Click the File Types tab, scroll down and select JAR File type. Press the Advanced button. In the Edit File Type dialog box, select open in Actions box and click Edit... Press the Browse button and navigate to the location the Java interpreter javaw.exe. In the Application used to perform action field, needs to display something similar to C:\Program Files\Java\j2re1.4.2_04\bin\javaw.exe" -jar "%1" % (Note: the part starting with 'javaw' must be exactly like that; the other part of the path name can vary depending on which version of Java you're using) then press the OK buttons until all the dialogs are closed.
这是从这里偷来的:http://windowstipoftheday.blogspot.com/2005/10/setting-jar-file-association.html
其他回答
如果你需要分发你的.jar文件,让它可以在其他人的Windows电脑上运行, 你可以在命令提示符中创建一个简单的.bat文件:
java -jar MyJavaTool.jar
并将.bat文件放在与.jar文件相同的目录中。
步骤:
1.)在谷歌上搜索“Java SE Runtime Environment”:https://www.google.com/search?q=Java+SE+Runtime+Environment
2.)在你的电脑上安装合适的版本
在Windows Vista或Windows 7中,手动文件关联编辑器已被删除。
最简单的方法是运行Jarfix,这是一个很小但功能强大的免费工具。只要运行它,你的Java应用程序就回来了…会了。
如果你有一个名为Example.jar的jar文件,请遵循以下规则:
打开notepad.exe 编写:java -jar示例 保存扩展名为。bat 将其复制到包含.jar文件的目录 双击它以运行.jar文件
编译:
javac -cp ".;./mysql-connector-java-5.0.8.jar;mybatis-3.0.1.jar;ibatis-2.3.0.677.jar" MainStart.java
为运行:
java -cp ".;./mysql-connector-java-5.0.8.jar;mybatis-3.0.1.jar;ibatis-2.3.0.677.jar" MainStart