The difference between (filename.jar) and (java -jar filename.jar)

I'm just wondering why, if I type the command line filename.jar, it displays a message (I can’t find the main class), but if I type java -jar filename.jar, the jar file works fine. Can someone explain to me why this is happening?

+3
source share
4 answers

The jar file is not executable. java -jar- The correct way to start it.

0
source

Java is an interpreter-based language, and you must provide the jar file as input to the executable interpreter.

Tell me if I'm wrong.

PS: Downvoters or editors, please indicate the reason. The end of half of them simply repeats the sentence while editing.

0

.jar Windows Mac OS. ( , , , Java)

, jar , java, java -jar jar .

, Java, , jar Java, java -jar .

, , .

.jar , .zip ( .zip ). jar/zip META-INF/MANIFEST.MF, , java -jar.

, , . ​​ unzip, , :

unzip -p _ .jar META-INF/MANIFEST.MF

jar META-INF/MANIFEST.MF:

jar xf _ .jar

  • ?
  • Java?
  • META-INF/MANIFEST.MF?
0

Just to clarify the situation, Java is a programming language for which you want to run the Java virtual machine, after creating the project, you create a class and enter some code into it, and then when you compile the compiler, create a .class file and then you you will need a Java virtual machine to run this .class file created by the compiler. The jar file is not executable, it is zipped in pkzip format, so each jar file contains a MANIFEST file in which it tells mainClass to start the ball (run the program). To start the jar, you use the commandjava -jar <jarfile>

0
source

All Articles