简体   繁体   中英

How to make a Java program be opened by default with Java, on any computer

When I send Java games I created to friends, the JAR file I send them often looks like a RAR file to them. This is because Windows on their computers thinks this file should be opened by WinRar.

They have JRE on their computers, but the default on Windows is that the file they recieve should be opened by WinRar.

The people I send my program can't be expected to guess, that what they need to do is specifically tell Windows to open the file with Java.

Is there a way to make it so that a JAR file I send to somebody, will be opened on his/her computer by default using the JRE?

Thanks a lot

You can consider adding a BATCH script. Something like java -jar YourJarName.jar

You will need two of them - for unix and windows:

Windows start.bat:

java -jar YourJarName.jar

Unix start.sh:

#!/bin/bash
java -jar YourJarName.jar

您可以使用Launch4J之类的工具将JAR文件包装为可执行文件。

You can convert your JAR file to executable file using Java Launcher .

OR

As @lan Roberts answer You can use Launch4j to wrap your JAR to executable. You can download it from this .

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