Ubuntu: How to open jar file using open JDK?



Question:

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.


Solution:1

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.


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »