Correct way to (re)launch a Java application with hardware-dependent VM parameters?

Posted by LowLevelAbstraction on Stack Overflow See other posts from Stack Overflow or by LowLevelAbstraction
Published on 2010-03-03T10:02:29Z Indexed on 2010/03/20 2:21 UTC
Read the original article Hit count: 311

Filed under:
|
|

EDIT I don't want to use Java Web Start

I've got a Java application that I'd like to run with different VM parameters depending on the amount of memory the system it is launched on has.

For example if the machine has 1 GB of memory or less I'd like to pass "-Xmx200m" and "-Xmx400m" if it has 2 GB and "-Xmx800m" if it has 8 GB (these are just examples).

Is there a portable way to do this?

I've tried having a first tiny Java app (hence portable) that determines the amount of memory available and then launches a new Java app but I don't think this is very clean.

As of now I've written Bash shell scripts that invoke the Java app with the correct parameters depending on the config but it only works on Linux on OS X.

What is the correct way to solve this?

Would application packager package ;) help ?

© Stack Overflow or respective owner

Related posts about java

Related posts about jvm