I have a spring boot project with 3 main classes
com.abc.test --> Application
com.abc.test.pqr --> ApplicationMain2
com.abc.test.xyz --> ApplicationMain3
Now spring boot project is unable to build so I have given POM entry as
<properties>
<start-class>com.abc.test.Application</start-class>
</properties>
From eclipse I am able to run all 3 Main successfully and create a jar. But whenever I am trying to run jar with command its running Application class.
java -jar -Dloader.main=com.abc.test.pqr.ApplicationMain2 test-1.0.jar
With following commands giving error of class not found
java -cp test-1.0.jar -Dloader.main=com.abc.test.pqr.ApplicationMain2
java -cp -Dloader.main=com.abc.test.pqr.ApplicationMain2 test-1.0.jar com.abc.test.pqr.ApplicationMain2
java -classpath test-1.0.jar com.abc.test.pqr.ApplicationMain2
Thanks a lot Ashish Command I used to run was
java -cp test-1.0.jar -Dloader.main=com.abc.test.pqr.ApplicationMain2
The problem is we are not including PropertiesLauncher. Along with class we are also required to give path of property launcher explicitly. So correct command is as below
java -cp test-1.0.jar -Dloader.main=com.abc.test.pqr.ApplicationMain2 org.springframework.boot.loader.PropertiesLauncher