如何在startup.bat中设置多个JAVA_OPTS选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18982083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set multiple JAVA_OPTS options in startup.bat
提问by Mono Jamoon
I am trying to pass multiple parameters when I start tomcat through startup.bat. I tried adding these lines at the top of startup.bat file, however they do not work.
当我通过startup.bat启动 tomcat 时,我试图传递多个参数。我尝试在 startup.bat 文件的顶部添加这些行,但是它们不起作用。
set JAVA_OPTS="-Dapplication.home=E:\webapp -Dfilepath=D:\newFolder\conf\con.properties"
Initially I was running the application with just one parameter -Dapplication.home=E:\\webapp
which worked fine. Now I need to pass another parameter and this method fails. Please advice.
最初我只使用一个运行良好的参数运行应用程序-Dapplication.home=E:\\webapp
。现在我需要传递另一个参数,这个方法失败了。请指教。
On running, I get this exception a FileNotFoundException
:
在运行时,我收到此异常 a FileNotFoundException
:
java.io.FileNotFoundException: E:\webapp -Dfilepath=D:\newFolder\conf\con.properties (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
The code is reading the entire segment as a single argument.
代码将整个段作为单个参数读取。
采纳答案by Evgeniy Dorofeev
try without quotes
尝试不加引号
set JAVA_OPTS=-Dapplication.home=E:\webapp -Dfilepath=D:\newFolder\conf\con.properties
should work
应该管用
回答by jay
set JAVA_OPTS=%JAVA_OPTS% -Dapplication.home="E:\\webapp"
设置 JAVA_OPTS=%JAVA_OPTS% -Dapplication.home="E:\\webapp"
set JAVA_OPTS=%JAVA_OPTS% -Dfilepath="D:\\newFolder\\conf\\con.properties"
设置 JAVA_OPTS=%JAVA_OPTS% -Dfilepath="D:\\newFolder\\conf\\con.properties"