Jean-Pierre Fournier wrote:
> 
> Does anyone know how one could get the same
> functionality as the -verbose option when
> starting a JVM from the commandline from
> within java or C?
> 

Do something like this in your C code:

#define USER_OPTIONS = "-verbose";
#define OPTS_SEPARATOR = "\s";
#ifdef JNI_VERSION_1_2
    JavaVMInitArgs vm_args;
    JavaVMOption options[1];
    options[0].optionString = USER_OPTIONS;
    vm_args.version = 0x00010002;
    vm_args.options = options;
    vm_args.nOptions = 1;
    vm_args.ignoreUnrecognized = JNI_TRUE;
    res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
#endif /* JNI_VERSION_1_2 */

Unfortunately, JNI in 1.1.x doesn't give you a way to specify JVM init
arguments when you create a Java VM from native code. If you can be
absolutely sure that all your deployment will be on Java 2, then the
above will do the trick for you.

Incidentally, we recently published a book on JNI, called "The Java
Native Interface", by Sheng Liang. It's part of The Java Series from
Addison/Wesley, and I've found it to be an excellent reference (and I'm
pleased that we *finally* published a reference on JNI - it's about
time!).    

-- 
Jeff Galyan
http://www.anamorphic.com
http://www.sun.com
jeffrey dot galyan at sun dot com
talisman at anamorphic dot com
Sun Certified Java(TM) Programmer
======================================================================
Linus Torvalds on Microsoft and software development:
"... if it's a hobby for me and a job for you, why are you doing such a
shoddy job of it?"

The views expressed herein do not necessarily reflect those of my
employer.

Sun Microsystems, Inc., has no connection to my involvement with the
Mozilla Organization.


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to