1

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.

Mandar Pandit
  • 2,171
  • 5
  • 36
  • 58
user1907849
  • 960
  • 4
  • 19
  • 42

2 Answers2

3

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
Jens
  • 67,715
  • 15
  • 98
  • 113
  • While running the program, It gives "Could not load main class Ucp" – user1907849 Jun 12 '14 at 05:48
  • @user1907849 is the main method in class Ucp? – Jens Jun 12 '14 at 05:50
  • @user1907849 you hae to add the mainclass at the end of your statement. If Server is your mainclass you have to use this command: `java %JAVA_OPTS% –cp .Server Server`. If your class has a packagename you have to enter it before the second Server. – Jens Jun 12 '14 at 05:58
  • I Found the mistake I was doing , the correct command is java %JAVA_OPTS% –cp . Server, there is space between . and Server – user1907849 Jun 12 '14 at 06:22
2

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%.

Khanna111
  • 3,627
  • 1
  • 23
  • 25