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.
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
Running .jar File on Linux - Stack Overflow
How do I run Jar files on linux - Oracle Forums
What is the correct way to run a jar
How can I run a .jar file through the Linux beta?
Videos
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.
First, try running it on the command-line, with
java -jar <file.jar>
The user.dir property is cross-platform (see here) so it should not be the problem. However, are you using correct file separators? Remember it's '/' on UNIX and '\' on Windows.
The code line you gave works fine on linux.
My best guess is that you're then trying to use this directory path by adding a windows-specific path separator (like path + "\subdir") which isn't appropriate for linux (you should build a new File object instead).
Either that, or your jar file isn't being executed at all. Have you tried doing something very simple in your jar file to see if anything is being run? Have you tried running your jar with java -jar myapp.jar to see if any exceptions are thrown or error messages displayed?
several ways:
appending
&at the back. However, using this, the program will still be terminated if you closed the terminal that started the program.Start a
screensession, and start the program inside it; you can detach thescreensession and close the terminal. Later on, you can attach to the session again and found yourself back on the console as if you've been there all along. However, you will need to start a screen session before running the program, and if you forgot to do that, you can't do anything about it.Use
disownjob control from your shell. This will detach the task from your tty and your program won't be terminated when the tty is closed. However, I don't think there's any way to reattach a disowned job.
A command line prompt I have always used for long run times to last through logoffs is "nohup" so in your case is
nohup java -jar test.jar &
The & is important so you can get another shell running. I believe this will not last through reboots.