调用jar文件时出现意外的java.lang.IllegalArgumentException

时间:2013-08-20 02:59:08

标签: java command-line jar options

我正在尝试使用建议here的一些额外的java选项运行Jenkins war文件,但我得到了例外:

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at Main._main(Main.java:288)
        at Main.main(Main.java:98)
Caused by: java.lang.IllegalArgumentException: Multiple command line argument specified: -XX:+CMSClassUnloadingEnabled
        at winstone.cmdline.CmdLineParser.parse(CmdLineParser.java:68)
        at winstone.Launcher.getArgsFromCommandLine(Launcher.java:391)
        at winstone.Launcher.main(Launcher.java:359)
        ... 6 more

1 个答案:

答案 0 :(得分:10)

我的同事指出,我的问题是我在选项之前指定了jar文件:

nohup nice /usr/bin/java -DJENKINS_HOME=/opt/jenkins/CI -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York -Djava.awt.headless=true -jar jenkins.war -XX:MaxPermSize=2048m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

应该是:

nohup nice /usr/bin/java -DJENKINS_HOME=/opt/jenkins/CI -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York -Djava.awt.headless=true -XX:MaxPermSize=2048m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -jar jenkins.war

简单的错误,但(除了文档,我不幸地掩盖了),我还没有看到任何地方的XX选项必须在java命令行的jar文件之前。