I want to add the below parameters to JAVA_TOOL_OPTIONS. Could anyone please help me how to add these?
set JAVA_TOOL_OPTIONS=-Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF8
If i add like above, will it work?
I tried setting the above command but i am not sure whether java picks these two parameters or not?
Experts help would be much appreciated.
I tried setting this variable in my windows environment with Java 7 and doing java -version
it gives me it set this variable , as shown as follows
C:\Users\ajduke>set JAVA_TOOL_OPTIONS=-Djava.net.preferIPv4Stack=true -Dfile.e
ncoding=UTF8
C:\Users\ajduke>java -version
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF
8
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b145)
Java HotSpot(TM) Client VM (build 21.0-b15, mixed mode, sharing)
Previous answer works for Windows. For unix based environment you should follow these steps:
Edit /etc/profile adding line:
export JAVA_TOOL_OPTIONS='-Djava.net.preferIPv4Stack=true -Dfile.encoding="UTF-8"'
Run
source /etc/profile
This will set global environment variable JAVA_TOOL_OPTIONS for all users immediately.
In case only the first argument is picked up: DON'T USE QUOTES ! Just the arguments:
set JAVA_TOOL_OPTIONS=-Xms128m -Xmx512m
In my case (Windows), only the first argument was picked up and reported to be invalid, since I used
set JAVA_TOOL_OPTIONS="-Xms128m -Xmx512m"
and starting any java app results in:
Picked up JAVA_TOOL_OPTIONS: "-Xms128m -Xmx512m"
Invalid initial heap size: -Xms128m -Xmx512m
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
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.