5

I am able to run a Java program through Eclipse by setting the VM arguments as -Xmx1024m -Xms256M. Now I want to run the same Java program (jar) through a .bat file in Windows. I am setting the JVM values in the 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 batch (.bat in Windows XP) it throws Out of Memory error and I suspect that the JVM setting through the .bat file is not working.

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
IS_EV
  • 988
  • 2
  • 15
  • 29

2 Answers2

11

It should be _JAVA_OPTIONS instead of JAVA_OPTS.

Danyel
  • 2,180
  • 18
  • 32
3

Use the arguments directly

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

You don't need to set them at JAVA_OPTIONS. To be sure that your application is using the parameters that you want:

  • open jvisualvm that comes with java. Just type "jvisualvm" at command line if you have set java correctly at your path.
  • open the vm started to your application.
  • check under "JVM Arguments" in the "Overview" tab.

There should be set your jvm options.

Caesar Ralf
  • 2,203
  • 1
  • 18
  • 36
  • I have to pass some input paramentes as arguments from the command prompt. so in reality my bat file is java -cp TA.jar com.myClass %1 %2 . In this case where should I place the JVM paramters as per your approach. – IS_EV Jan 31 '13 at 20:21
  • you could set it before the -cp. Editing the answer. – Caesar Ralf Jan 31 '13 at 20:24