我有一个名为helloworld.jar的JAR文件。 为了运行它,我在命令行窗口中执行以下命令:
java -jar helloworld.jar
这工作得很好,但我如何执行它与双击? 我需要安装什么软件吗?
我有一个名为helloworld.jar的JAR文件。 为了运行它,我在命令行窗口中执行以下命令:
java -jar helloworld.jar
这工作得很好,但我如何执行它与双击? 我需要安装什么软件吗?
当前回答
步骤:
1.)在谷歌上搜索“Java SE Runtime Environment”:https://www.google.com/search?q=Java+SE+Runtime+Environment
2.)在你的电脑上安装合适的版本
其他回答
开始。球棒是唯一对我有用的东西。
打开一个文本文档并输入。Java -jar,不管你叫。jar
另存为start.bat,保存在与要执行的.jar文件相同的文件夹中。然后运行。蝙蝠
步骤:
1.)在谷歌上搜索“Java SE Runtime Environment”:https://www.google.com/search?q=Java+SE+Runtime+Environment
2.)在你的电脑上安装合适的版本
不幸的是,这并不容易,因为微软在最近的Windows版本中删除了高级文件关联对话框。-对于较新的Windows版本,您可以只指定将用于打开.jar文件的应用程序。
修复在Windows上打开.jar文件需要两个步骤。
Open the Control Panel, and chose "Default Programs -> Set Associations". Find .jar extension (Executable JAR file) there, and pick Java as default program to open this extension. It will probably be listed as "Java Platform(SE)". A faster alternative perhaps is straightforward right-click on a .jar file, and then change associated program by clicking on the "Change..." button. Now open the regedit, and open the HKEY_CLASSES_ROOT\jarfile\shell\open\command key. Luckilly for us, we may specify parameters there for the (Default) value. On my Windows system it looks like: C:\app\32\jre7\bin\javaw.exe" -jar "%1" %* but in most cases it is the following string: C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
注:
不要在那里使用java.exe,因为它会打开shell窗口。 本线程中提到的jarfix工具很可能只是为您修改注册表。我更喜欢手动注册表更改方法,因为这意味着系统管理员可以将注册表更改“推送”到网络中的所有工作站。
你需要检查一些东西;如果这是您自己的jar文件,请确保在清单中定义了main类。因为我们知道您可以从命令行运行它,所以要做的另一件事是创建一个windows快捷方式,并修改属性(您必须四处查看,我没有windows机器可以查看),以便它在打开时执行的命令是您提到的java -jar命令。
另一件事是:如果某个东西没有混淆,它就应该工作;检查并确保已将Java与.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