问题
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.
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.
On running, I get this exception 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.
回答1:
try without quotes
set JAVA_OPTS=-Dapplication.home=E:\\webapp -Dfilepath=D:\\newFolder\\conf\\con.properties
should work
回答2:
set JAVA_OPTS=%JAVA_OPTS% -Dapplication.home="E:\\webapp"
set JAVA_OPTS=%JAVA_OPTS% -Dfilepath="D:\\newFolder\\conf\\con.properties"
来源:https://stackoverflow.com/questions/18982083/how-to-set-multiple-java-opts-options-in-startup-bat