How do I mark a .jar file as executable on Xubuntu 13.04?
Solution 1
Assuming the file in question is in your $HOME (just move it with the GUI otherwise), open a terminal (that much should be easy :) then run this command:
chmod a+x jarfile.jar
Change jarfile.jar
to the actual name of the file in question of course. If that gives you an error, the file is probably not owned by your user, so try again with sudo
:
sudo chmod a+x jarfile.jar
Solution 2
Jar files are supposed to be executed like I've shown below (assuming you have configured JRE/JDK in the execution search path):
java -jar /path/to/jarfile.jar
You CANNOT directly execute a JAR file even if you add the execute bit. By itself bash
is simply not able to understand it.
A simple shell script will be ideal to run Minecraft, for example:
#!/bin/bash
java -Xms1024M -Xmx1024M -jar /path/to/mincraft.jar
Related videos on Youtube
![Ben](https://i.stack.imgur.com/rpDxT.png?s=256&g=1)
Ben
Just a Xubuntu user that knows a small amount about terminals and is trying to learn.
Updated on September 18, 2022Comments
-
Ben almost 2 years
I'm trying to get the minecraft.jar file to execute , but the check box won't come up when I go to Properties > Permissions. I don't know much about the terminal and its commands so if someone could post a simple step by step solution on how to mark it that would be great. People keep saying to use a chmod command but I have no idea what that is, so you are forewarned if I say "over my head".
-
RobotHumans almost 11 yearsjars don't need to be executable. you can launch them with an interpreter just like python and have a launcher script (which I think is the generally accepted practice).
-
Richard almost 11 yearsHave you tried right clicking the jar, and selecting "Open With > OpenJDK (or whatever java)"?
-
-
Ben almost 11 yearsI have had it work on 12.04 before but not this time so I don't know what to do.
-
kiri almost 11 yearsFiles in your home directory should not be owned by root
-
kiri almost 11 years@Ben Is it on your system drive or a external disk?
-
Ben almost 11 yearsIt worked perfectly!
-
kiri almost 11 yearsYou are able to mark it as executable then open it with a double click. You just need to associate the MIME type with Java JRE
-
Ben almost 11 yearsand I need 15 rep
-
terdon almost 11 years@minerz029 that depends on who put them there. There is nothing that stops them from being owned by root. Try
sudo touch foo; ls -l foo
. -
Terry Wang almost 11 yearsThis is desktop environment specific, not flexible if JVM arguments need to be passed;-) But you are right anyway, double click executes jar files in DE/WM.
-
terdon almost 11 yearsWHat about self-extracting jar files?
-
kiri almost 11 yearsI said should not. With normal use, nothing in your home folder should be owned by anyone except yourself.
-
terdon almost 11 years@minerz029 I understood that to be a prescriptive should rather than a hypothetical :). Anyway, that's not entirely true, there are various things that can end up in your $HOME, try
find ~/ -user root
, you might be surprised.