How to install JAR file in Ubuntu

Java programs are commonly distributed online as Jar files. This is a file with a .jar extension.

Running a JAR file is straightforward:

$ java -jar foo.jar

But what if I want to have this program appear in my Dash, like other programs? Here is how I usually solve this:

  • I place the JAR file in a ~/bin directory in my home directory.

  • I add the invocation to run the JAR file as a menu item using the Main Menu tool. After it is added, it will appear in Dash when searched by its name.

Do note that the tilde symbol does not work, you will need to provide the full path.

Tried with: Alacarte 3.10.0 and Ubuntu 14.04


How to add program to Open With in Ubuntu

You get a list of applications when you try the Open With option to open a certain type of file. If you try to associate a new application to open a certain type of file, you are shown a list of applications. The list of applications shown is the list of .desktop files in the /usr/share/applications directory.

Programs written by you or shared by a friend or compiled from source may not install their .desktop file in the /usr/share/applications directory. It takes a bit of work to get such a program added to the Open With list in Ubuntu. This post shows the details of how to achieve this. I use a method that is a bit easier.

  • First we need to create a .desktop file for your program. I find that the easiest way to do this is using the alacarte application. Installing and using alacarte is easy. Create a New Item using the name of your program. This creates a file of the name ~/.local/share/applications/alacarte-made.desktop.

  • Copy the above file somewhere and find the Exec section in the file. For example, this section might be:


Append a %F parameter to it:

Exec=foobar %F

This enables the .desktop file to be used to open a file using this program.

  • Finally copy this file to /usr/share/applications:
$ sudo cp alacarte-made.desktop /usr/share/applications

Your program should now appear in the list of Open With applications 🙂

Tried with: Ubuntu 14.04

How to edit Dash entries using Main Menu

Main Menu
Main Menu

Since Ubuntu does not have the traditional Start menu, it is not obvious how to perform basic operations on the Dash. For example, to add or remove program entries to be launched from the Dash.

An easy way to edit the Dash entries is using the Main menu program. This program can be installed easily:

$ sudo apt-get install alacarte

Once installed, it can be opened from the Dash by typing Main menu or by typing alacarte at the terminal.

You can do these operations using Main Menu:

  • Add or remove program entries to launch from the Dash.
  • Change the icon. To do this click on the icon image shown for the program.
  • Specify if the program should be launched from a terminal.

Main Menu creates an entry by creating a .desktop file in ~/.local/share/applications.

Tried with: Main Menu 3.10 and Ubuntu 14.04