Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting JAVA_OPTS in windows using command prompt

Tags:

java

java-opts

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.

like image 443
user1907849 Avatar asked Apr 23 '26 20:04

user1907849


2 Answers

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
like image 89
Jens Avatar answered Apr 26 '26 10:04

Jens


Windows uses "%JAVA_OPTS% rather than "$JAVA_OPTS" which is UNIX/LINUX. You can check if the environment is updated with JAVA_OPTS by echoing that: echo %JAVA_OPTS%.

like image 40
Khanna111 Avatar answered Apr 26 '26 10:04

Khanna111



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!