How to run application from war?

17,397

Exactly like running application from jar file:

java -cp yourwarfile.war com.yourcompany.YourMainClass

Share:
17,397
user710818
Author by

user710818

Updated on June 14, 2022

Comments

  • user710818
    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
    Axel Knauf over 12 years
    And if the .war file has a manifest with a Main-Class defined, running java -jar yourwarfile.war should be enough. Works e. g. for jenkins.war.
  • user710818
    user710818 over 12 years
    I think because that it is war, not jar file. Paths are different.
  • AlexR
    AlexR over 12 years
    Please 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 use find "YourMainClass" instead of grep
  • user710818
    user710818 over 12 years
    Thanks you for useful comment. I found that class in WEB-INF/classes. But in Class-Path in manifest is possible only put jars.
  • AlexR
    AlexR over 12 years
    Although 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 probably Class-Path: /classes or Class-Path: ./classes. I believe one of them should work.