简体   繁体   English

在Windows 7上运行.jar文件

[英]Run a .jar file on Windows 7

I have downloaded a .jar file and it won't run on my computer. 我已经下载了一个.jar文件,它将无法在我的计算机上运行。 I have installed Java RE 5.0 and have Java 7 update 72. Every time I double click on the file it pops up and closes. 我已经安装了Java RE 5.0,并安装了Java 7 update72。每次我双击该文件时,它都会弹出并关闭。

I have reinstalled the java re and java 7u72 and still no success. 我已经重新安装了Java re和Java 7u72,仍然没有成功。

Any help with running executable .jar file on windows 7? 在Windows 7上运行可执行文件.jar文件有帮助吗?

The .jar file must have a lib folder in the folder the .jar is in to open a window (without using native java libraries). .jar文件必须在.jar所在的文件夹中有一个lib文件夹才能打开窗口(不使用本机Java库)。 If it doesn't, then the .jar won't open any windows, as it needs external libraries to do so. 如果没有,那么.jar将不会打开任何窗口,因为它需要外部库来打开。 However, if your .jar isn't meant to open any windows, then it has been performing as expected. 但是,如果您的.jar并不想打开任何窗口,则说明它已按预期运行。 Try running your .jar from the command line: 尝试从命令行运行.jar:

java -jar <jar-file-name>.jar

Have you checked the Environment Variables? 您是否检查过环境变量? Maybe the variable PATH is not specified. 也许未指定变量PATH Besides, you can try this: 此外,您可以尝试以下操作:

Start - "Control Panel"
Click on "Default Programs"
Click on "Associate a file type or protocol with a specific program"
Double click on the .jar
Browse C:\Program Files\Java\jre7\bin\javaw.exe
Click on the button Open
Click on the button OK

If it doesn't work, try to configure the Environment Variables: 如果不起作用,请尝试配置环境变量:

From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Note: You may see a PATH environment variable similar to the following when editing it from the Control Panel: 注意:从“控制面板”进行编辑时,您可能会看到类似于以下内容的PATH环境变量:

%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

Variables enclosed in percentage signs (%) are existing environment variables. 用百分号(%)括起来的变量是现有的环境变量。 If one of these variables is listed in the Environment Variables window from the Control Panel (such as JAVA_HOME), then you can edit its value. 如果在“控制面板”的“环境变量”窗口中列出了这些变量之一(例如JAVA_HOME),则可以编辑其值。 If it does not appear, then it is a special environment variable that the operating system has defined. 如果未出现,则它是操作系统定义的特殊环境变量。 For example, SystemRoot is the location of the Microsoft Windows system folder. 例如,SystemRoot是Microsoft Windows系统文件夹的位置。 To obtain the value of a environment variable, enter the following at a command prompt. 要获取环境变量的值,请在命令提示符下输入以下内容。 (This example obtains the value of the SystemRoot environment variable): (此示例获取SystemRoot环境变量的值):

echo %SystemRoot%

More info here 更多信息在这里

Hope it helps. 希望能帮助到你。

Clemencio Morales Lucas. 克莱门西奥·莫拉莱斯·卢卡斯。

默认情况下,java不在Windows模式下运行,也许只是一个控制台Java程序。

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

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