简体   繁体   中英

Command line - call class from jar which is in war

I have a .war file. Inside this .war file I have WEB-INF folder. Inside WEB-INF I have a lib folder and inside this lib folder I have a .jar file. Inside this jar I have a class with main method. I need to call this method. Can I do this from command line? I don't have an option of deplying war file, so I need a command which will access my class with main method through the war file.

最简单的方法是从命令提示符处转到jar文件所在的位置,然后键入java youpackagename.yourclassname例如, java net.grinder.Grinder

Accessing the jar in the war package might be difficult. Due to the fact that war packaging is intended for deployment on a Java Web server, the war packaging is obsolete and not handy for you usecase. Unzip the war archive and run the contained jar archive after unpacking like you'd run any other jar archive with java -jar /path/to/archive.jar (you'll find a ton of examples on this page).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM