Wednesday, June 5, 2013

Make .Jar Files execute from file manager in Fedora 16 / Gnome 3 (Or just creating your own MIME types)

I have a few .Jar applications that I wanted to be able to execute as a regular application from within Gnome 3 but everytime I double clicked them it wanted to open File Roller Gnome's archave manager.

I did not want to open a terminal everytime I wanted to execute a .Jar file just to type java -jar {filename} so i did a little research and made it work with the double click and now I want to make sure everyone else knows how to do it.

First I edited /usr/share/applications/defaults.list

Output from Diff of /usr/share/applications/defaults.list

diff defaults.list /home/viroscope/Original\ Files/defaults.list
< application/x-java-archive=java.desktop;
> application/x-java-archive=gnome-file-roller.desktop;
What this means is I changed gnome-file-roller.desktop to the at the time nonexistant file java.desktop

Second I edited /usr/share/applications/mimeinfo.cache

Output From Diff of /usr/share/applications/mimeinfo.cache

diff mimeinfo.cache /home/viroscope/Original\ Files/mimeinfo.cache
< application/x-java-archive=java.desktop;
> application/x-java-archive=gnome-file-roller.desktop;
Here this means I changed gnome-file-roller.desktop to again the non-existant file java.desktop

Lastly I created the java.Desktop file in /usr/share/applications and it's contents are:

[Desktop Entry]
Name=Movie Player
Comment=Execute Java .jar Files From File Manager
Exec=java -jar %f

Then all you do is log out and back into gnome and the .jar files run on double click.