How to add more than one parameter to JAVA_TOOL_OPTIONS

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:

  1. Edit /etc/profile adding line:

    export JAVA_TOOL_OPTIONS='-Djava.net.preferIPv4Stack=true -Dfile.encoding="UTF-8"'

  2. Run

    source /etc/profile

This will set global environment variable JAVA_TOOL_OPTIONS for all users immediately.

Tags:

Windows

Java