Recently, when I was in the process of installing and using JavE - an ASCII art editor, each time I wanted to run the editor, I had to open up a terminal, navigate to the directory containing the JavE binary and then execute the command :
$ java -jar jave.jar
After some time, this whole job of opening the terminal and typing the command became quite tedious. And I started wondering if it was possible to start the editor by just double clicking on the jar file. But double clicking on it opened the jar file in the Gnome archive manager which was not what I wanted. I even tried associating the command 'java -jar' with all jar files in Nautilus. But to no avail.
That was when I remembered that Nautilus has a special feature which allows one to pass file names to scripts from the file manager. Gnome has a special folder by name nautilus-scripts/ which resides inside the hidden directory '.gnome2/' in ones home folder. The full path for the nautilus-scripts/ in my home directory being '/home/ravi/.gnome2/nautilus-scripts/'. And any executable script that one drops in this directory will be accessible from the Gnome right click menu.
So I created a bash script by name 'Run_Java' and saved it in the folder '/home/ravi/.gnome2/nautilus-scripts/'. And voila! I was able to access and run the script by right-clicking anywhere on the Gnome desktop or file manager and selecting the script (See picture).
#File Name: Run_Java
java -jar $1
In the above listing, the $1 contains the value of the first parameter - which in this case was the name of the JavE jar file. You can access the nautilus-scripts/ directory in Nautilus file manager by navigating to File Menu -> Scripts -> Open scripts folder.
This is a very useful feature and opens up a lot of avenues as most GUI tools in GNU/Linux accept command line parameters. For instance, one can open a Jpeg image in Gimp from the command line by passing the name of the image file as a parameter to Gimp. So by writing a bash script and saving it in this magic folder, one can select a group of image files in Nautilus and right-click and select the relevant script to open all the selected files in Gimp.
But not every one is proficient in writing scripts you say ? No problem, there is a site by name g-scripts maintained by Shane.M who has taken it upon himself to collect and make available nautilus scripts suitable for diverse purposes. The afore mentioned site contains a large collection of scripts, some of which were written by Shane himselves and others collected from different sources on the net.