No 'Open with' option to open/run jar file with openjdk

Solution 1:

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'.