简体   繁体   中英

java command-line args on tomcat7

We have a grizzly-jersey application whose main() takes java command line args(org.kohsuke.args4j) and fed into a class called Features.java which looked something like below

@Option(name = "--enableAuthentication", usage = "--enableAuthentication=true/false")
private static String  enableAuthentication = Boolean.TRUE.toString();

we used to deploy the web application as JAR.

Now we moved to WAR model, and we are using tomcat7 as the servlet container.
- how do I pass those cmd line args INTO this application
- how do I access those cmd line args IN the application

Environment
jersey 2.9 + spring
tomcat 7.0.46
java8
ubuntu 12.04
maven

in tomcat 7, under bin directory create set setenv.sh file

add following line

-D--enableAuthentication=true/false

This should work.

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