1

I installed "open jdk 7" on ubuntu 13.04, but not recognized in "other application" list to set as default. I need to open a ".jar" file with "open jdk7". Please help.

4
  • The executable you want to associate with is "java", not "openjdk". Is that in the list?
    – Ash
    Commented Jul 21, 2013 at 5:16
  • Hi Ash, thank you for answer.When I right click on ".jar" file and select "open with" the "oracle java runtime" and "open jdk" are in list but not in default. I want to set one of "java" or "open jdk" as default, but when I go >>> right click > properties > open with to set as default, none of "java" or "open jdk" are in list. Only "oracle java 7 web start" is in list.
    – Alex
    Commented Jul 21, 2013 at 13:40
  • 1
    I'm not sure, does this help: askubuntu.com/a/224480/121193 ?
    – Ash
    Commented Jul 22, 2013 at 10:52
  • @Ash thank you for answer, I used your posted link above and fixed my problem.
    – Alex
    Commented Jul 22, 2013 at 14:19

2 Answers 2

6

1. First you need to have installed java. Can install from Software Center or by following command in terminal. (Open terminal with pressing Ctrl+Alt+T ).

sudo apt-get install openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless

2. Right click on the .jar file and select Open With Openjdk Java 6/7 Runtime

enter image description here

** If there is no Open With Openjdk Java 6/7 Runtime option in menu, then select Open with and then select Openjdk Java 6/7 Runtime

** If it is not even in the Open with then select Other Aplication... and select Openjdk Java 6/7 Runtime

enter image description here

enter image description here

** If it is even not found here, then select Show other apllications Button. Here you can select Openjdk Java 6/7 Runtime

enter image description here

** If it is not even in Show other apllications list, you need to done something in Terminal

i. Open terminal with pressing Ctrl+Alt+T .

ii. Paste this in terminal prompt and Enter.

gksudo gedit '/usr/share/applications/openjdk-7-java.desktop'

iii. In the resulting gedit document, Change the NoDisplay=true line to NoDisplay=false: then save the file and close it.

enter image description here

iv. Then you will able to find Openjdk Java 6/7 Runtime in any of the above Open with menu.

3. Another method is to create a Desktop icon to launch this .jar file application. To do that :

i. In terminal run gksudo gedit /usr/share/applications/[NAME OF THE APPLICATION].desktop

** Replace the [NAME OF THE APPLICATION] with .jar file name.

iI. Add the following lines to the resulting empty gedit. Replace the text in [ ] with appropriate. Then save it and close.

[Desktop Entry]
Encoding=UTF-8
Name=[APPLICATION NAME]
Comment=[WHAT EVER]
Exec=java -jar [DIRECTORY OF THE FILE]/[FILE NAME.JAR] %F
StartupNotify=true
Terminal=false
Type=Application
Icon=/usr/share/icons/gnome/256x256/apps/[ANY ICON YOU LIKE IN THIS FOLDER]
NoDisplay=false
MimeType=applications/php

iii. You will able to find the icon for this application in Dash. You can open the .jar file application by click on it.

1
  • For me, run with JRE option (steps until "If it is not even in Show other apllications list") is there only for JRE 6, not for JRE 7.
    – Suma
    Commented Jul 26, 2015 at 11:57
0

If none of the previous answers work, you can try this:

How do I reenable opening jar files by double clicking on them?

but if you are using Ubuntu 14.04, you must make a small change in step 1 and 5.

In ubuntu 14.04, the application's name is openjdk-7-policytool.desktop and not openjdk-7-java.desktop.

So, make the changes like this:

Step 1 :

cd /usr/share/applications
ls -l openjdk-7-policytool.desktop

Step 5.

application/x-jar=openjdk-7-policytool.desktop
application/x-java-archive=openjdk-7-policytool.desktop

Then reboot and you are done. Now the java files should be open with Open JDK 7 by default.

Note: To double-click and run, make sure the file has execute permissions.

1
  • If your answer is essentially a referral to another question, it would be better to flag this question as a duplicate of the other (with the [flag] button below this one). If you think the cited answer is outdated or needs other improvements, please suggest an edit to it and don't create a new answer. Commented May 10, 2015 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .