|

How to Run Jar File in Ubuntu Linux

Got a Jar file but struggling to execute it? Learn how to run a Jar file in Ubuntu and other Linux distributions.

How to execute Jar file in Ubuntu and other distributions

A Jar file is basically a Java executable file. So you must have Java installed on your system. If you have Java installed in your Ubuntu, you should be able to run it either by double clicking or by selecting from right click options.

The problem here is that most Linux distributions don’t come with Java pre-installed. So please make sure to install Java on Ubuntu or whichever distribution you are using.

You only need the Java Runtime Environment and you can install it using the command below in Ubuntu-based distributions:

sudo apt install default-jre

Even with Java installed, sometimes running a Java application is not as straightforward as double-clicking the icon. You might have to go through a few steps.

When I tried to open the .jar file by double clicking, I was presented with the following error:

Ubuntu Run Java Jar Error
File not executable error

Fixing this error is very trivial. Right click the .jar file, and open properties.

Ubuntu Run Java Jar Menu
Right click on Jar file and click Properties

Now in the properties menu, open the ‘Permissions’ tab. Enable the ‘Allow executing this file as program’ checkbox.

Ubuntu Run Java Jar Permission Set
Enable Execution of the file under the Permissions tab

Now, you can simply double click the .jar file to launch the application, AndroMouse in my case. You can see that it works without any problems.

Ubuntu Run Java Jar App Running
Java App Running

You have to keep in mind that you have to enable the ‘Allow executing as program’ permission for every .jar application you download. It is disabled by default as a security measure. You should enable it only for the applications that you trust and know are safe.

Further troubleshooting Jar file not running on Linux

Even if you have Java Runtime Environment installed and execution permission set, in some older versions of Ubuntu, the Jar file won’t run. Here’s a fix for that.

Right click on the .jar file and choose the option “Open With Other Application“:

Ubuntu Jar Files

Now on the next screen, select the option Show other applications:

In other applications, if you do not find option for Java, install the Java Runtime Environment first. Normally, you should be able to see the option Open With OpenJDK Java x Runtime. Select it and successfully run it.

Enjoy running Jar file on Ubuntu!

Bonus tip: Run jar file from the terminal

Running the jar file from terminal has its advantages. It may show helpful error messages if the jar file doesn’t run successfully.

In the terminal, use the command like this:

java -jar filename.jar

I hope this short guide was useful to all of you. Which Java based applications do you use? Do you have any other problems with them? Let me know in the comments below!

Similar Posts

  • java -jar not working for me, it says

    java -jar demo.jar
    Error: JavaFX runtime components are missing, and are required to run this application

  • jre/lib/amd64/server/libjvm.so cannot open shared object file: No such file or directory

    this happens with every freaking game ran in java on linux. I just assume this is dead linux software and I should use windows for this.

  • I am running Ubuntu Linux. My first foray into Java & JavaFX was a digital dashboard for my antique motorhome. Running it from the terminal is a bit awkward inside a vehicle so I wanted to run from a desktop icon. After much searching I found this web page. The instructions worked perfectly. Thanks to its foss for the help.

    • Hi dude,you can create a”app launcher”,on the Desktop area,you right click,”create launcher”,then you choose the”path to desktop”and a icon,there is a lot of tutorials on YT,how to create a ubuntu s app launcher