Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot get JAVA_OPTS to work

843829May 19 2010 — edited May 20 2010
Hi,

Have a problem getting the JAVA_OPTS env-parameter to work.

I am on a Windows XP system with JRE 1.6.0_12, and have written a test-class:
package info;

import java.lang.management.ManagementFactory;
import java.lang.management.MemoryUsage;

public class MemInfo {

	public static void main(String[] args) {
		MemoryUsage mu = ManagementFactory.getMemoryMXBean()
				.getHeapMemoryUsage();

		Long mIni = mu.getInit();
		Long mMax = mu.getMax();
		Long mUse = mu.getUsed();

		System.err.println("ini=" + mIni);
		System.err.println("max=" + mMax);
		System.err.println("use=" + mUse);
		System.err.println(mu.toString());
	}
}
When I run it with:
  java -Xms1g -Xmx1g info.MemInfo
I get the expected output (max heap size=1GB):
ini=1073741824
max=1065484288
use=1321224
init = 1073741824(1048576K) used = 1321224(1290K) committed = 1065484288(1040512K) max = 1065484288(1040512K)
But when I try to do the same, using JAVA_OPTS:
set JAVA_OPTS=-Xms1g -Xmx1g
java info.MemInfo
I get the default values output (max heap size=1GB) :
ini=0
max=66650112
use=206032
init = 0(0K) used = 206032(201K) committed = 5177344(5056K) max = 66650112(65088K)
Isnt JAVA_OPTS supposed to work like this?
Or what am I missing?

/rop
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2010
Added on May 19 2010
3 comments
3,201 views