How to Run Jar File in Ubuntu Linux

Downloaded a JAR file and don't know how to use it? Learn how to run JAR files in Ubuntu based Linux distributions.

If you install any package having the .jar extension and try to execute it, it may throw an error saying "The file is not marked as executable":

jar file not marked as executable

And in this tutorial, I will walk you through how you can install its prerequisites and run Jar files in Ubuntu and other Linux with multiple methods.

Run jar files in Ubuntu

If you don't know, JAR stands for Java ARchive so you must have a working Java environment.

If you have Java installed, you should be able to run it. Check if Java is installed with:

java --version

If you see an error instead of the version number, install Java runtime environment using the following command:

sudo apt install default-jre

Once you're done with installing the prerequisite, you can follow any of the two given methods to run jar files:

  • Using GUI
  • Using the terminal

So let's start with the first one.

Method 1: Using GUI

The first step is to open the file manager from the system menu and navigate to the jar file which you want to run.

Then, right-click on the jar app and select Properties.

From there, select Permissions and enable Allow executing file as program :

make file executable using file manager

That made the file executable.

But you have yet to select which app it should use to run the jar files.

To select an Application to start the jar files, again, click on the jar file and choose the second option Open with Other Application and choose the OpenJDK Java Runtime option:

Running Jar file in Ubuntu with double click

That's it.

Now, you can start the jar application like you do with any other files by pressing the Enter key.

In my case, it was an installer and it started as it should:

running jar file in Ubuntu

Method 2: Using the Terminal

If you believe in efficiency, I'm about to show you the terminal method will complete the task in only three commands.

First, open the terminal and navigate to the directory where the jar file is located using the cd command:

cd /path/to/jar_file

Once done, use the chmod command with the +x flag to make the file executable:

chmod +x Filename.jar

And finally, you can use the Java command with the -jar flag to run the jar file:

java -jar Filename.jar

That's it!

Here's how to set up the JAVA_HOME variable

Most of the users set the JAVA_HOME variable incorrectly. So we thought, why not make a dedicated guide to get things done correctly?

Here's how you set up the JAVA_HOME variable correctly:

How to Set JAVA_HOME Variable in Ubuntu Linux Correctly
If you are running Java programs on Ubuntu using Eclipse, Maven or Netbeans etc, you’ll need to set JAVA_HOME to your path. Otherwise, your system will complain that “java_home environment variable is not set”. In this beginner’s tutorial, I’ll show the steps to correctly set

I hope you will find this guide helpful.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world


Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.