Monday, February 16, 2015

Making an application Launcher for a Java(Jar) Application

After installing the Java runtime environment you can create a launch icon like other applications in the sistem by making a *.desktop file.
It makes things easier and prettier!
  • Create a folder in a directory of your choice with the *.jar (the application) and *.png (the application icon) files. In this case the directory I will use is /usr/share/folder. For the ~/folderis a good idea to name it with the application name, for example, if the application is VUE name the folder ~/VUE or ~/vue.
    Open the terminal and run the following code line:
    sudo mkdir /usr/share/folder
    Or open your file manager (Nautilus in this case) with super admin privileges by runing the following code line in the terminal:
    gksu nautilus
    After that, go to /usr/share and create the folder folder with the GUI.
  • Also in the terminal and run the following code line:
    sudo gedit /usr/share/applications/*.desktop
(You could use your editor of choice. In this case was used Gedit.)
  • Paste the following code lines in the file you are editing:
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Icon[en_US]=/usr/share/HomeAccountant/HomeAccountant.png
    Name[en_US]=HomeAccountant
    Exec=java -jar /usr/share/HomeAccountant/HomeAccountant.jar
    Comment[en_US]=Home Accountant
    Name=HomeAccountant
    Comment=Home Accountant
    Icon=gnome-panel-launcher
  • Save the file.

No comments: