Setting JAVA_OPTS in windows using command prompt

user1907849 picture user1907849 · Jun 12, 2014 · Viewed 15.5k times · Source

I am running the java program on windows server 2012, I want to set the JAVA_OPTS variable and use it, here is how I am doing it:

Open a command prompt in the bin of jdk where it is installed ,and executing the following command :

$set JAVA_OPTS = “-Xdebug , server=y”

Then in the next line in the command prompt only , when I try to run

$java $JAVA_OPTS –cp .Server

(where Server is the name of the java program), I get an error saying that: Could not find or load assembly $JAVA_OPTS. Please let me know what mistake I am doing here. I am not using IDE for this purpose.

Answer

Jens picture Jens · Jun 12, 2014

on windows you have to set the variable like:

set JAVA_OPTS = “-Xdebug , server=y”

and use it this way

java %JAVA_OPTS% –cp .Server