1

I want to understand what happens when I run:

java -jar some.jar

from command line.

I know that in order to launch a java program, it must contain main() method so should I assume that the jar file I am running has such main() method in one of its classes and just runs it by default? In such case, what if there is more than one class that has main() method as I don't believe there are any restrictions on how many classes can have main() methods.

DevO
  • 19
  • 3
  • Look into configuring the JAR manifest file, in which you can specify a specific class as an entry point. – Tim Biegeleisen Nov 14 '17 at 05:47
  • Have a look at [Working with Manifest Files](https://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html), in particular [Setting an Application's Entry Point](https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html) – MadProgrammer Nov 14 '17 at 05:47
  • https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html – Pavel Nov 14 '17 at 05:49

0 Answers0