Ubuntu – How to run an executable file through JRE by default

defaultdefault-programsexecutablejava

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?

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