dev@glassfish.java.net

Re: Specifying JVM options through environment variables

From: Byron Nevins <Byron.Nevins_at_Sun.COM>
Date: Wed, 28 Oct 2009 10:30:40 -0700
V2 Answer

Easy Solution:
    There is a script in a directory named "bin" under your domain directory.  In there is a script named "startserv[.bat]"    Edit this script.  Use this script to start the domain.
I'm not sure if the -D you send in from the script will make it out to the domain as a System Property but you can test it.  I'm not setup for V2 right now...


Sander Sõnajalg wrote:

Hi,

I think this is more like a question to the as-admin CLI developers.. i'm not too sure which is the best list to post it to so i just sent it to dev and admin, hopefully that's okay : )

Ok, I'm really in stuck with one thing, I'd really appreciate if someone could help me out on this one. Namely, i really need to set JVM options to the glassfish server THROUGH setting them into my system environment variables *before* invoking the asadmin. After digging around in your source code repo i'm quite convinced this should somehow be possible (e.g. http://fisheye5.cenqua.com/browse/glassfish/admin-cli/framework/src/java/com/sun/enterprise/cli/framework/CommandLineParser.java). So what i want to achieve would be something like this to work:

$ export SOME_ARGUMENT_THAT_ASADMIN_WOULD_READ='-Dmy.framework.enabled=true'
$ asadmin start-domain myDomain
[and now myDomain starts with "java -jar blablabla -Dmy.framework.enabled=true"]

How can i do this? I have really searched quite a bit for the solution, but not found it : //

(The need for that kind of thing rises from extending your eclipse glassfish WTP plugin. I can make eclipse export my variable into the environment before executing the server. If you take a look at the implementation of the com.sun.enterprise.jst.server.sunappsrv.SunAppServerLaunch#launch(), you'll see that you haven't really left any room for third-party non-hack extensions to that plugin. I need to add a tab to the Eclipse WTP Glassfish launch configuration that would let the user set some additional JVM arguments, and making eclipse set them to the system environment really seems to be the only way.. in case even this path *is* doable, i.e. it is somehow possible to feed my arguments to asadmin like that.

Any help greatly appreciated! : )

Cheers,
Sander