2012-01-16 41 views
4

我試圖通過添加JAVA_OPTS在增加tomcat的內存catalina.bat中如下:JAVA_OPTS語法在catalina.bat中

rem TITLE   (Optional) Specify the title of Tomcat window. The default 
rem     TITLE is Tomcat if it's not specified. 
rem     Example (all one line) 
rem     set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%] 
rem 
rem 
rem 
rem $Id: catalina.bat 1146096 2011-07-13 15:20:43Z markt $ 
rem --------------------------------------------------------------------------- 

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
-server -Xms1536m -Xmx1536m 
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
-XX:MaxPermSize=512m -XX:+DisableExplicitGC 
-XX:UseConcMarkSweepGC 
-XX:CMSPermGenSweepingEnabled 
-XX:CMSClassUnloadingEnabled" 

但在運行啓動時或當我得到在CMD下面的錯誤關機腳本:

'JAVA_OPTS' is not recognized as an internal or external command, 
operable program or batch file. 
'-server' is not recognized as an internal or external command, 
operable program or batch file. 
The filename, directory name, or volume label syntax is incorrect. 
The filename, directory name, or volume label syntax is incorrect. 
The filename, directory name, or volume label syntax is incorrect. 
The filename, directory name, or volume label syntax is incorrect. 
The filename, directory name, or volume label syntax is incorrect. 

請通知我爲什麼讓他們。

回答

15

嘗試:

set JAVA_OPTS=-Djava.awt.headless=true -Dfile.encoding=UTF-8^
-server -Xms1536m -Xmx1536m^
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m^
-XX:MaxPermSize=512m -XX:+DisableExplicitGC^
-XX:+UseConcMarkSweepGC^
-XX:+CMSClassUnloadingEnabled 
  • 您需要使用set命令來設置環境變量。
  • 如果你想在Windows bat文件拆分多行命令,你需要在每行的末尾添加^(尖)。
  • 沒有必要的引號。
+0

我得到的錯誤:'無法識別的VM選項「UseConcMarkSweepGC」 無法創建Java虛擬machine.' – 2012-01-16 09:07:40

+0

您的選項不正確。將其更改爲:'-XX:+ UseConcMarkSweepGC' – dogbane 2012-01-16 09:11:46

+0

我要爲'-XX做同樣的:CMSPermGenSweepingEnabled^ -XX:CMSClassUnloadingEnabled' – 2012-01-16 09:13:14

-3

認沽反斜槓在行的末尾:\

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 \ 
-server -Xms1536m -Xmx1536m \ 
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m \ 
-XX:MaxPermSize=512m -XX:+DisableExplicitGC \ 
-XX:UseConcMarkSweepGC \ 
-XX:CMSPermGenSweepingEnabled \ 
-XX:CMSClassUnloadingEnabled" 
+0

-1這是windows,而不是unix,所以反斜槓將無法工作。 – dogbane 2012-01-16 08:49:41

0

嘗試在每個新行的末尾刪除空的空間。

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8[ENTER] 
-server -Xms1536m -Xmx1536m[ENTER] 
...