简体   繁体   English

默认情况下,如何在任何计算机上使用Java打开Java程序

[英]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. 当我将创建的Java游戏发送给朋友时,发送给他们的JAR文件通常看起来像RAR文件。 This is because Windows on their computers thinks this file should be opened by WinRar. 这是因为Windows在其计算机上认为该文件应由WinRar打开。

They have JRE on their computers, but the default on Windows is that the file they recieve should be opened by WinRar. 他们在计算机上安装了JRE,但是Windows上的默认设置是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. 不能期望我发送程序的人猜测,他们需要做的就是专门告诉Windows使用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? 有没有一种方法可以使我发送给某人的JAR文件默认情况下使用JRE在他/她的计算机上打开?

Thanks a lot 非常感谢

You can consider adding a BATCH script. 您可以考虑添加BATCH脚本。 Something like java -jar YourJarName.jar java -jar YourJarName.jar东西

You will need two of them - for unix and windows: 您将需要两个-用于Unix和Windows:

Windows start.bat: Windows start.bat:

java -jar YourJarName.jar

Unix start.sh: Unix start.sh:

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

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

You can convert your JAR file to executable file using Java Launcher . 您可以使用Java Launcher将JAR文件转换为可执行文件。

OR 要么

As @lan Roberts answer You can use Launch4j to wrap your JAR to executable. 作为@lan Roberts的答案,您可以使用Launch4j将JAR包装为可执行文件。 You can download it from this . 您可以从这里下载它。

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

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