Unable to set jvm parameters / arguments (Xmx and Xms) via .bat file

I can run the java program through eclipse by setting the VM arguments to -Xmx1024m -Xms256m. Now I want to run the same java program (jar) via a .bat file in windows. I set the JVM values ​​in a file as follows

@echo off set JAVA_OPTS="-Xmx1024m -Xms256m -XX:+HeapDumpOnOutOfMemoryError" java -cp TA.jar com.myClass 

But when I run the same program through the package (.bat in windows xp), it gives an "Out of Memory" error, and I suspect that setting up the JVM through the .bat file does not work.

Can anyone help?

+4
source share
2 answers

Use arguments directly

 java -Xmx1024m -Xms256m -XX:+HeapDumpOnOutOfMemoryError -cp TA.jar com.myClass 

You do not need to set them to JAVA_OPTIONS . To make sure your application uses the right options:

  • open jvisualvm that comes with java. Just type "jvisualvm" at the command line if you installed java in your path correctly.
  • open vm running in your application.
  • check in the "JVM Arguments" section of the " Overview " tab.

Jvm options must be set.

+2
source

It should be _JAVA_OPTIONS instead of JAVA_OPTS.

+11
source

All Articles