Ubuntu – How to execute a .jar file from the terminal

command linejava

I know that to execute a file, I use the . command, then the file name with a space between them. But I'm trying to execute a .jar file using the . and it does not work. I went into the properties and marked it as executable and made it run with Java.

Is there a way to execute a file with Java in the Bash Terminal?
I am trying to execute a Minecraft.jar file

I am trying to execute the Minecraft.jar file.

Best Answer

  • The . syntax can only be used to run (by "sourcing") shell scripts.

    You'll need to use the java command to run a .jar file:

    java -jar Minecraft.jar

    If you don't have java installed, you can fix that by installing the default-jreยน package. You can see if you already have java installed by running in a terminal:

    java -version 

    [1]: This will install the default openjdk Java runtime. You can use openjdk-8-jre, or openjdk-7-jre, or openjdk-6-jre instead, if you prefer - whichever is available on your version of Ubuntu.

  • Related Question