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.
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.
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 first make sure you have Java installed, then do the following in a console:
Install binfmt-support Support for extra binary formats:
The binfmt_misc kernel module, contained in versions 2.1.43 and later of the Linux kernel, allows system administrators to register interpreters for various binary formats based on a magic number or their file extension, and cause the appropriate interpreter to be invoked whenever a matching file is executed. Think of it as a more flexible version of the #! executable interpreter mechanism.
sudo apt-get install binfmt-supportcdto your JAR file and change it to executable (you can also do this through file properties in Nautilus)chmod a+rx myjar.jarRun your jar file just as if it was any other binary executable or shell script
./myjar.jar
Note: Be sure you have binfmt_misc Linux kernel module loaded. If you use your custom compiled kernel without this module, binfmt-support won't work.
Running a from class inside your JAR file load.jar is possible via
java -jar load.jar
When doing so, you have to define the application entry point. Usually this is done by providing a manifest file that contains the Main-Class tag. For documentation and examples have a look at this page.
The argument load=2 can be supplied like in a normal Java applications:
java -jar load.jar load=2
Having also the current directory contained in the classpath, required to also make use of the Class-Path tag. See here for more information.
For example to execute from terminal (Ubuntu Linux) or even (Windows console) a java file called filex.jar use this command:
java -jar filex.jar
The file will execute in terminal.
Videos
I run gentoo, and have installed a dual boot of debian 12 to confirm that just installing java, jre, and openjdk does in fact not allow me to run .jar programs.
I am trying to install fabric to minecraft so I can add some mods to minecraft I want. Except that even with the software from here: https://wiki.gentoo.org/wiki/Java
and from here: https://packages.gentoo.org/packages/dev-java/openjdk
does not give me any program to open my fabric installer jar program to install it with. I have set the jar as a executable, but it still won't let me open it with any java programs. There are none.
Any help, even lazy help, is appreciated. Thank you for reading
FIX: you run them in terminal, which confused me since the tutorial I watched showed it as a program. Thanks for the help people. Haven't modded minecraft since I used windows
I made a jar executable. Im wondering how to run it from anywhere as a normal command?
I figured that i could create an alias to
java -jar /path/of/the/jar
but it does not seems right. I feel like it would make more sense to do something like adding it to the environment variable path or something like that.
What is the right way to do so? I basically want my command to work as ls, cd or cat does. I think...
Can someone help me? Because when I run a .jar file on fedora java -jar name_of_app.jar nothing is popping up can someone help?