简体   繁体   中英

Run a .jar file on Windows 7

I have downloaded a .jar file and it won't run on my computer. 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.

I have reinstalled the java re and java 7u72 and still no success.

Any help with running executable .jar file on windows 7?

The .jar file must have a lib folder in the folder the .jar is in to open a window (without using native java libraries). If it doesn't, then the .jar won't open any windows, as it needs external libraries to do so. However, if your .jar isn't meant to open any windows, then it has been performing as expected. Try running your .jar from the command line:

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

Have you checked the Environment Variables? Maybe the variable PATH is not specified. 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:

%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. 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. 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):

echo %SystemRoot%

More info here

Hope it helps.

Clemencio Morales Lucas.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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