Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I make "double click to run" the default behaviour of a jar-file on Nautilus? There is no "Open with OpenJDK Java 7 Runtime" on the "Open with" tab under Properties.

share|improve this question
    
Bug report on Launchpad –  pcworld Sep 2 '13 at 21:20
add comment

1 Answer

up vote 12 down vote accepted

You can try the following:

If you have OpenJDK Java 7 Runtime installed in your system, then you should have a file named openjdk-7-java.desktop in the folder /usr/share/applications/

Check if you have the .desktop file.

  1. Go to the terminal and type:

    cd /usr/share/applications

    ls -l openjdk-7-java.desktop

  2. If the result is:

    -rw-r--r-- 1 root root 367 Oct 24 22:29 openjdk-7-java.desktop

  3. Then (to associate OpenJDK Java 7 Runtime to the java files) you can edit the file defaults.list also in the folder /usr/share/applications/ .

  4. In the terminal type:

    sudo gedit /usr/share/applications/defaults.list

  5. Search for application/x-jar and application/x-java-archive in the defualts.list, and change the .desktop file to the openjdk-7-java.desktop and save the changes.

Screenshot of gedit /usr/share/applications/defaults.list

Now the java files should be open with Open JDK 7 by default. To double-click and run, make sure the file has execute permissions.

You can set the permissions in the terminal with: chmod 755 file.jar or right click in the file, permissions tab and click in "Allow executing file as a program"

File properties

Finally double-click in the file to run it.

Hope this will helpful!

Regards.

share|improve this answer
    
Thank you very much, that solved my problem! –  FBA Dec 2 '12 at 14:53
    
This solved my problem too. For later readers of this topic, this is also working on 13.04. –  denNorske Apr 21 '13 at 9:37
    
unfortunately this doesn't work on 13.10, the defaults.list already has openjdk-7-java.desktop in there and the jar file I'm trying to run is already marked executable, and still jar files give the error about being blocked because it's not executable. Also checked and verified that the java binaries and all links through the chain to them are executable. –  Matrix Mole Dec 1 '13 at 9:16
add comment

protected by Community Apr 27 '13 at 17:26

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.