5

I have been looking at this question and although it shows how you can execute a jar in Windows, it does not show how this can be done in Linux (preferably CentOS). How can I execute the .jar file I made in Linux?

Here is what I have on the command line:

[support@turndownForWhat project]$ ls
DICOMFLOW.jar  jre1.7.0_60

UPDATE: I have tried this:

[support@turndownForWhat project]$ sudo jre1.7.0_60/bin/java -jar DICOMFLOW.jar
[sudo] password for support:
sudo: jre1.7.0_60/bin/java: command not found

I ran:

[root@turndownForWhat project]# ls -l jre1.7.0_60/bin/java
-rw-rw-r-- 1 support support 5718 Apr 17  2014 jre1.7.0_60/bin/java
Community
  • 1
  • 1
ryekayo
  • 2,341
  • 3
  • 23
  • 51

5 Answers5

4

It's pretty much the same, just without the .exe:

<path_to_jre>/bin/java -jar Executable.jar
that other guy
  • 116,971
  • 11
  • 170
  • 194
3

Based on your reported output, the java command is not executable. This is likely an issue with the copying or uncompressing of the JRE directory.

martinez314
  • 12,162
  • 5
  • 36
  • 63
  • I unzipped jre-6u41-linux-i586.bin with "unzip jre-6u41-linux-i586.bin" successfully. but I still get the error. so how to solve it? – wuppi Jun 13 '15 at 18:10
1

It's the same as executing in Windows:

<path to bin folder for the specific JRE>/java  -jar Executable.jar

Make sure you can ls to the directory with the same path.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Chiseled
  • 2,280
  • 8
  • 33
  • 59
1

It does not matter whether the JAR file was created on Linux or Windows or is to be executed on Mac. That's why it is called portable.

Just use the java -jar command with the specific JRE you want to use (add the path of the bin folder or create an alias ans use something like java7 -jar ...).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dici
  • 25,226
  • 7
  • 41
  • 82
0

"C:\Program Files\Java\jdk-11.0.15\bin\java" -jar jenkins.war

sajeeth
  • 47
  • 2
  • 9
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – rikyeah Apr 20 '22 at 18:51