7

I have a big war file, that contains many classes with main method.

How I can point Java to run main specific class?

1
  • Check whether, they are packaged into jar file..? Commented Dec 18, 2011 at 14:25

1 Answer 1

9

Exactly like running application from jar file:

java -cp yourwarfile.war com.yourcompany.YourMainClass

5
  • 5
    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.
    – Axel Knauf
    Commented Dec 18, 2011 at 14:34
  • I think because that it is war, not jar file. Paths are different.
    – user710818
    Commented Dec 18, 2011 at 14:45
  • 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
    – AlexR
    Commented Dec 18, 2011 at 14:56
  • Thanks you for useful comment. I found that class in WEB-INF/classes. But in Class-Path in manifest is possible only put jars.
    – user710818
    Commented Dec 18, 2011 at 15:01
  • 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.
    – AlexR
    Commented Dec 18, 2011 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.