Can I run a JAR file on any OS?

Is it possible to execute a JAR file on any OS (e.g. Windows, Linux, Mac OS X)? I want to create a simple application that I want to run on Linux, Windows and Mac OS X. Can the JAR file run on any OS with java installed?

+3
source share
5 answers

Jar files run on any OS for which a JVM exists.

+9
source

Yes, if you do not use any native libraries (JNI), this is how Java works. It is platform independent.

+8
source

, , ​​Java , . , JAR , , ( Windows , ).

JAR JAR . , , JAR , , Java (JVM) . JAR , :

java -jar myprogram.jar

JAR JAR, JAR . JAR :

java -classpath path/to/your/program.jar com.mypackage.Main
+6

Jar , ​​ JVM. jar, , Java, , (, Windows), .

+4

, , (, java -jar name.jar.) .

0

Source: https://habr.com/ru/post/1746089/


All Articles