For some reason the desktop file for OpenJDK is not installed, even though this file is listed.
$ apt-file list openjdk-8-jre | grep desktop
openjdk-8-jre: /usr/share/applications/openjdk-8-java.desktop
openjdk-8-jre: /usr/share/applications/openjdk-8-policytool.desktop
$ ls -l /usr/share/applications/openjdk-8-java.desktop
ls: cannot access /usr/share/applications/openjdk-8-java.desktop: No such file or directory
$ dpkg --get-selections | grep openjdk-8
openjdk-8-jre:amd64 install
But you can also use Oracle Java(TM):
Install Oracle Java(TM) with this commands and you have an entry in open with:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
To select your default Java, use the following command.
sudo update-alternatives --config java
But this has no influence on the menu item "Open with"
For some reason there is no desktop file for OpenJDK 7.
$ apt-file list openjdk-7-jre | grep desktop
openjdk-7-jre: /usr/share/applications/openjdk-7-policytool.desktop
$ dpkg --get-selections | grep openjdk-7
openjdk-7-jre:amd64 install
Install Java with this commands, in order to get the required entry:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
and then
sudo apt-get install oracle-java7-set-default
Or you could create a desktop
file for OpenJDK7
Create a new file in ~/.local/share/applications/
nano ~/.local/share/applications/openjdk7.desktop
and add the lines below:
[Desktop Entry]
Encoding=UTF-8
Name=Open JDK 7 Runtime
Comment=Open JDK 7 Runtime
Exec=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -jar %f
Terminal=false
Type=Application
Icon=java
MimeType=application/x-java-archive;application/java-archive;application/x-jar;
NoDisplay=true
Replace the line
Exec=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -jar %f
with the location of your java installation. You can check the installed JREs with:
update-alternatives --display java
Sample output
java - auto mode
link currently points to /usr/lib/jvm/java-9-oracle/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java - priority 1071
slave java.1.gz: /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
/usr/lib/jvm/java-8-oracle/jre/bin/java - priority 1083
slave java.1.gz: /usr/lib/jvm/java-8-oracle/man/man1/java.1.gz
/usr/lib/jvm/java-9-oracle/bin/java - priority 1084
Current 'best' version is '/usr/lib/jvm/java-9-oracle/bin/java'.
Best Answer
Maybe you don’t have the runtime environment installed!
To install it try the following instructions.
Or you could install Oracle JRE using the PPA method with the following commands.
Then to use it to open .jar files try the following.