Q:

Creating a menu item generically in Linux

For part of a large university project I have built a large java based application. To make "installation" cleaner I am aiming to write a script to copy the jar to a hidden file in the users home directory then add a menu &/Or desktop launcher.
Since I do not know what platform the markers shall be using it seems sensible to make this generic so I was going to build a shell script and a batch file.
The shell script starts off simple, check the directory doesnt already exist, make it and copy the file accross.
Then it comes to making a launcher of some kind. I presume each desktop environment shall do things differently.
After 10 minutes with google it seems everything suggested is autotools but since I have no knowledge of this it seems a bit overkill.
Is there an easy way to achieve what i need?
Thanks

A:

These days, basically all of the desktop environments uses desktop files.  For the specification for those files, see the Desktop Entry Specification.
Normally, they're put in /usr/share/applications on the system.  Those files are then read and used to construct the menu.
If you have the ability to write to the system /usr/share/applications directory, that's obviously simplest, but if you had that, you would probably be putting the JAR file somewhere other than a hidden directory in the user's home directory.
If not, the path that's supposed to be honored is ~/.local/share/applications.  If you drop a desktop file in there, it should show up for the user.  (This is somewhat newer; I don't think GNOME 2 supports, it for example.  Older desktop environments had various special places for these files.)
Then, the problem basically reduces to figuring out what to write for the Exec line in the desktop file.  (See the desktop files on your system in /usr/share/applications for some examples.)  If you're lucky, you can get away with just sticking a java command in there, but the details will depend on your application.

