Discussion:
How to specify -Xms -Xmx from within the program?
(too old to reply)
Princess Morgiah
2004-06-12 15:33:57 UTC
Permalink
Hi,

I was wondering if it were possible to specify the -Xms and -Xmx from
within a program.

Allthough it is possible to specify these parameters from the commandline,
it's not a handy way of doing things for users. I don't know whether or not
these parameters can be set from within a manifest file in a jar, but that
would also mean starting the program as a jar, which is not very handy while
developing the software.

Therefor I would like to know if it were possible to specify these, and
other settings from withing the code itself.

After a quick look at the System class, I found a setProperty method but I
don't think that's the way to go.

Any ideas on this one?

Thanks in advance,

Princess Morgiah
Oscar kind
2004-06-12 22:22:16 UTC
Permalink
Post by Princess Morgiah
I was wondering if it were possible to specify the -Xms and -Xmx from
within a program.
No. These settings determine what the JVM does, and programs only
determine what they do themselves.
Post by Princess Morgiah
Allthough it is possible to specify these parameters from the commandline,
it's not a handy way of doing things for users. I don't know whether or not
these parameters can be set from within a manifest file in a jar, but that
would also mean starting the program as a jar, which is not very handy while
developing the software.
These parameters cannot be set in a jar file, but they can be specified in
a Java Web Start description file. Otherwise, use a scripts to start the
JVM and the program (you'll need one script for each platform the program
will run on).

Also note that if you use ANT to compile your program, you can also
automatically build a jar file to execute. This is actually an advantage:
- Your program is exactly as it will be delivered, making testing easier
and more reliable; you don't have to separately test a development and a
packaged version.
- You can include version information in the jar manifest and read it in
your program (note that ANT can automatically increase version numbers
and also creates the manifest for the jar file). I like this option.
Post by Princess Morgiah
Therefor I would like to know if it were possible to specify these, and
other settings from withing the code itself.
Not the memory settings of the JVM. Other (system) settings, if they can
be changed, can only be changed through java.lang.System. That is, unless
you're willing to use JNI. In that case you can do anything you have an
os-dependant library for.
Post by Princess Morgiah
After a quick look at the System class, I found a setProperty method but I
don't think that's the way to go.
Personally, I don't think that either. But that's more because I believe
that system settings should only be set by a sysadmin. It's unlikely (but
possible) that a Java program is a sysadmin's tool for setting system
settings.


kind regards,
Oscar
--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
Princess Morgiah
2004-06-13 15:47:13 UTC
Permalink
<snip>
Post by Oscar kind
These parameters cannot be set in a jar file, but they can be specified in
a Java Web Start description file. Otherwise, use a scripts to start the
JVM and the program (you'll need one script for each platform the program
will run on).
Since the program will not be started via Java Web Start, I think I'll have
to go with the script option.
Post by Oscar kind
Also note that if you use ANT to compile your program, you can also
- Your program is exactly as it will be delivered, making testing easier
and more reliable; you don't have to separately test a development and a
packaged version.
- You can include version information in the jar manifest and read it in
your program (note that ANT can automatically increase version numbers
and also creates the manifest for the jar file). I like this option.
Ant is indeed a very handy tool - I've used it in the past as well. Didn't
know about the option to increase version numbers, but it could be very
useful.

Thanks for your reply!

Princess Morgiah

Loading...