Re: How to specify -Xms -Xmx from within the program?

From: Oscar kind (oscar_at_danwa.net)
Date: 06/13/04


Date: Sun, 13 Jun 2004 00:22:16 +0200

Princess Morgiah <princess_morgiah_nospamplease@yahoo.com> wrote:
> 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.

> 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.

> 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.

> 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


Relevant Pages

  • Re: set vm-parameter when converting to jar?!
    ... > I have an application in jbuilder and want to make it into jar file. ... > my application as an vm-parameter and appearently when i make this jar ... I don't think you can force VM settings via the contents of a jar file, ...
    (comp.lang.java.programmer)
  • Re: Visual Studio 9 including the wrong CRT assembly.
    ... I also need to target the ... The manifest inside of my executables reveals that it is depending on both ... settings, which causes the resulting app manifest to contain references ... private assemblies.) ...
    (microsoft.public.win32.programmer.tools)
  • Re: ISA Issue
    ... Download and install the latest JVM from www.java.com. ... launching java applets. ... Clear the IE cache the ISA cache before retesting. ... default settings. ...
    (microsoft.public.windows.server.sbs)
  • Re: XP Styles with Visual Studio 2005
    ... In the linker settings go to "Manifest file". ... and "Manifest Resource File" to ... These are the default settings of new projects and new projects have XP ... Boycott DRM! ...
    (microsoft.public.win32.programmer.ui)
  • Re: VB or VC++ for DirectShow programming ?
    ... I converted my old workspace to a "solution". ... to change those settings, but I'll take a look and see what got set. ... conflicted with the "generate manifest" setting (apparently set by default ... during the conversion). ...
    (microsoft.public.win32.programmer.directx.video)