0

This is been troubling me for a long time.

In Linux, I see a process cmdLine is like below :

/usr/java/jdk1.7.0_65/bin/java-Dsosa-Djava.security.policy=conf/sosa.policy-Dlog4j.configuration=properties/sosa-log4j.properties-Xms256m-Xmx1024m-classpath:/opt/HP/jboss/standalone/deployments/hpsa.ear/lib/sosa.jar:/opt/HP/jboss/standalone/deployments/hpsa.ear/lib/mwfm.jar

I understand:

 -D : we specify property
 -classpath : we specify the path to be searched 

Question: During JVM instance creation, how does java finds the main class or entry points if we have multiple jars/ears in the -classpath option.

I understand, We can specify the main class in MANIFEST file like :Main-Class: MyPackage.MyClass

But I see above jars does't have Main-Class entry in MANIFEST file.

  1. How does JAVA find, where to start, which class file has main?
  2. also If two jars in classpath have menifest file, specifying Main-Class, what happens ?
Semih Eker
  • 2,389
  • 1
  • 20
  • 29
sandejai
  • 931
  • 1
  • 15
  • 22
  • That's not your actual command line - you've missed out all the spaces, which really confuses things. Additionally, unless you specify `-jar` it's not going to try to find an entry point. Give us your *actual* command line and we can help. – Jon Skeet Dec 05 '14 at 13:39

1 Answers1

0

Once you check documentation to CLI java you will see there are only two options:

java [ options ] class [ arguments ]

here you specify the class you want to execute.. or

java [ options ] -jar file.jar [ arguments ]

you specify exactly one JAR file which (as you already know) must contain Main-Class in manifest.

sodik
  • 4,675
  • 2
  • 29
  • 47