Search code examples
javajava-opts

Setting JAVA_OPTS in windows using command prompt


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.


Solution

  • 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