Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Hello and welcome, jaorizabal. I slightly corrected your question. Maybe you can install a spell checker for your browser, to improve the next question yourself. Another hint: For text issues, you may mark text with your mouse in the terminal, and then paste it into the edit field of your browser (and elsewhere) with a middle click on the scroll wheel. Then you can layout your code with the buttons at the edit field. This is much faster than taking a screen shot, and uploading it. – user unknown Feb 6 '12 at 1:55
up vote 60 down vote accepted

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 openjdk-6-jre package. You can see if you already have java installed by running in a terminal:

java -version 
share|improve this answer
$ java -jar schemaSpy_5.0.0.jar *** Required parameter '-o' was not specified. *** – Karthik T May 13 '14 at 4:31

If it is an executable jar, then

java -jar Minecraft.jar 

Not all jar-Archives contain an executable class, declared to be started in the Manifest file, but if there is, this will work.

Btw.: You don't start most programs from the shell with the dot. The dot is a shortcut for source, and it only works in the bash and some other shells, to include a script in the scope of the current session.

A compiled binary xybin is simply started with its name if it is in the path:


or, with its absolute path:


or with its relative path:


or if you happen to be in the directory of the file, with this relative path:


The file has to be marked executable for you (see: chmod). All of the above is true for shellscripts too, but they often have an extension .sh, and you can start a shellscript by invoking the interpreter, and then it needn't be marked executable:


If you don't want to start a new bash, you can use source, and you do so, to consume function definitions, aliases and variable settings.

share|improve this answer

Linux is perfectly capable of running a foreign binary, like a JAR file. This is how Wine works, for example. To run JAR files as executable do the following in a console

sudo apt-get install binfmt-support

Cd to your JAR file and change it to executable (you can also do this through file properties in Nautilus)

chmod a+rx myjar.jar

Run your jar file just as if it was any other binary executable or shell script

share|improve this answer
Thanks! This is exactly what I was looking for. It's better than using java -jar because it doesn't require the host program to know that it is a java program, and it's better than using a script because you don't have to worry about passing through STDIN and OUT. – srlm Dec 6 '13 at 5:34

You might as well want to make a nice entry for the application in Unity. execute the following commands:

gedit ~/.local/share/applications/minecraft.desktop

In the window that pops up, copy and paste the following:

[Desktop Entry]
Comment=Click here to play Minecraft
Exec=java -jar /path/to/minecraft.jar

You might need to log out and back in to see the effects. :) Also you need to search the internet for a nice lookin Minecraft icon since they don't provide one with the download..

share|improve this answer
  1. Open a command prompt with CTRL+ALT+T
  2. Go to your ".jar" file directory. If your Ubuntu version / flavour supports it, you should be able to right click on your ".jar" file's directory and click "Open in Terminal"
  3. Type the following command:

    java -jar jarfilename.jar

This way your ".jar" file will execute.

share|improve this answer
 java -jar /home/username/.minecraft/launcher.jar
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.