Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I could do it with OpenJDK, but it didn't work for my purposes so I'm using Oracle's JRE 7. I can run the jar through the terminal with

java -jar filename.jar

and can also right click the file and click Open With > Oracle Java 7 Runtime, but I can't set the Java 7 Runtime by default in the Properties menu (probably because the runtime executable isn't located in /usr/bin).

Any quick command lines I can type to set it so I can just hit enter on the file and launch the .jar with Java 7?

share|improve this question
up vote 0 down vote accepted

I've had a similar question, and I found the answer, it was a missing .desktop file for me, and I included a guide to manually creating one (although I'm hoping that somebody will show me a better way) anyway, here is how I did it.

1) Open Gedit from the Terminal with root privileges usind gksu gedit

2) Open a .desktop file from /usr/share/applications and copy it into a new file.

3) Edit the name, comments, and image to your liking.

4) Change the command to java -jar %u DO NOT FORGET THE %u

5) Save

6) Right click .jar file in nautilus, select properties>open with>show all applications, and select the new entry, select either add or set as default.

share|improve this answer

Ubuntu Tweaks is a useful program that can manage this I think. Install and run it, then go to Admins > File Type Manager, select Category 'All' then find 'Java archive'. Edit that, and if it is not on the list, use the Add button, and select it, or use the 'Custom command' option at the bottom.

share|improve this answer

I gone through Internet and I came across one article with complete steps to run jar file

share|improve this answer
Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Eliah Kagan Jul 25 '12 at 7:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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