How run a .jar file with a double-click?

Maybe you don’t have the runtime environment installed!

To install it try the following instructions.

sudo apt-get install openjdk-7-jre

Or you could install Oracle JRE using the PPA method with the following commands.

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

Then to use it to open .jar files try the following.

  1. Right click the .jar file > Properties.
  2. Click on the “Open With” tab along the top.
  3. Change the default choice to be the java runtime environment that you have installed.
  4. Click Close and you should be ready to double click.

Adding a file called /usr/share/applications/java.desktop with following content should do the trick.

[Desktop Entry]
Name=Java
Comment=Java
GenericName=Java
Keywords=java
Exec=java -jar %f
Terminal=false
X-MultipleArgs=false
Type=Application
MimeType=application/x-java-archive
StartupNotify=true

After adding this file you should be able to find an entry called Java in the Open file with...-Dialog


To make Java open .jar files per default (i.e. double click) right click on any .jar file to select Properties. In the following window select the "Open With" tab to see e.g. the follwing choice:

enter image description here

Select your Java runtime and press Set as default to make this your default application to open .jar files.

Tags:

Java

Gui