How to run application from war?
17,397
Exactly like running application from jar file:
java -cp yourwarfile.war com.yourcompany.YourMainClass
Author by
user710818
Updated on June 14, 2022Comments
-
user710818 almost 2 years
I have a big war file, that contains many classes with main method.
How I can point Java to run main specific class?
-
Axel Knauf over 12 yearsAnd if the
.war
file has a manifest with a Main-Class defined, runningjava -jar yourwarfile.war
should be enough. Works e. g. for jenkins.war. -
user710818 over 12 yearsI think because that it is war, not jar file. Paths are different.
-
AlexR over 12 yearsPlease post your command line and snippet from
jar -vft yourwar.war | grep YourMainClass
. It really depends on where your class is. If you are on windows usefind "YourMainClass"
instead ofgrep
-
user710818 over 12 yearsThanks you for useful comment. I found that class in WEB-INF/classes. But in Class-Path in manifest is possible only put jars.
-
AlexR over 12 yearsAlthough I have never tried this I think you are wrong. Typically java class loader relate equally to jar files and directories. So try
Class-Path: classes
or probablyClass-Path: /classes
orClass-Path: ./classes
. I believe one of them should work.