> ## Content Index
> Fetch the complete content index at: https://itsfoss.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Run Jar File in Ubuntu Linux
- URL: https://itsfoss.com/run-jar-file-ubuntu-linux/
- Published: 2012-09-20T23:00:01.000Z
- Updated: 2023-07-06T11:58:35.000Z
- Description: Downloaded a JAR file and don't know how to use it? Learn how to run JAR files in Ubuntu based Linux distributions.
- Author: Abhishek Prakash
- Tags: Tutorial

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](https://itsfoss.com/content/images/2023/07/jar-file-not-marked-as-executable.png)

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 **J**ava ****AR**chive 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](https://itsfoss.com/install-java-ubuntu/) 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](https://itsfoss.com/content/images/2023/07/make-file-executable-from-the-File-manager.png)

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](https://itsfoss.com/content/images/2023/07/Select-openJDk-java-11-Runtime-to-run-jar-applications.png)

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](https://itsfoss.com/content/images/2023/07/the-installer-started.png)

### 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](https://itsfoss.com/cd-command/):

```
cd /path/to/jar_file
```

Once done, [use the chmod command](https://linuxhandbook.com/chmod-command/?ref=itsfoss.com) 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](https://itsfoss.com/set-java-home-ubuntu/):

[How to Set JAVA\_HOME Variable in Ubuntu Linux CorrectlyIf 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![](https://itsfoss.com/content/images/size/w256h256/2022/12/android-chrome-192x192.png)It's FOSSAbhishek Prakash![](https://itsfoss.com/content/images/wordpress/2021/09/set-java-home-ubuntu.png)](https://itsfoss.com/set-java-home-ubuntu/)

I hope you will find this guide helpful.