1

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

user3150201
  • 1,901
  • 5
  • 26
  • 29
  • 1
    You're asking if there's a way that you can make your stuff open how you define on a computer that isn't yours? It's Windows, so probably, but it would be unfortunate. – Dave Newton Jan 23 '14 at 15:05
  • I think that the better option is use a .cmd or .sh script. – Ernesto Campohermoso Jan 23 '14 at 15:07
  • I am curious why the default for a .jar file would be WinRar rather than Java. I would consider helping them to change the default application for .jar back to Java on their PCs. – Richard Chambers Jan 23 '14 at 15:12
  • This stackoverflow http://stackoverflow.com/questions/394616/running-jar-file-in-windows mentions an application called jarfix in one of the answers. – Richard Chambers Jan 23 '14 at 15:14
  • Thats not a problem of java, its a problem on your friends computer. Most likely WinRaR elected to set itself as the default program for jar files (a questionable choice), so its just a configuration issue. It can be easily fixed Explorer -> Right click on jar-file -> Open with -> Select javaw.exe (check "Always open with this program") – Durandal Jan 23 '14 at 15:27

3 Answers3

1

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
Mr. P
  • 1,387
  • 1
  • 11
  • 25
1

You could use a tool such as Launch4J to wrap the JAR file into an executable.

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
0

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.

ravibagul91
  • 20,072
  • 5
  • 36
  • 59