Skip navigation.
 
mlRe: delaying JVM launch time
FROM : Timothy J. Wood
DATE : Wed Dec 18 16:46:00 2002

On Wednesday, December 18, 2002, at 04:59  AM, Jesse Grosjean wrote:
>    NSString *path = @"Versions/A/Resources/Java/my.jar";
>    NSJavaVirtualMachine *vm = [NSJavaVirtualMachine
> defaultVirtualMachine];
>    [vm initWithClassPath:[path1 stringByAppendingString:path2]];
>    _myClass = [[NSClassFromString(@"com.hogbay.myClass") alloc] init];


  +defaultVirtualMachine will return an already initialized object,
thus, sending a -initWithClassPath: method to it will at best do
nothing and at worst break.  You might try doing the following:

  -- Call +[NSJavaVirtualMachine defaultClassPath]
  -- Append your jar path to this
  -- Call alloc/initWithClassPath: to create a new NSJVM

  Hopefully this will case the +defaultVirtualMachine to return the JVM
you initialized (which you can check by calling it after you init your
JVM and comparing pointers).


  If that doesn't work, you might look at the OmniJava source that we
publish at:

   http://www.omnigroup.com/ftp/pub/software/Source/MacOSX/Frameworks/

  This is what we use in OmniWeb to start the JVM, add class path
elements, extra security goo.  It is probably pretty heavy weight for
what you want, but you should be able to extract the JNI code to start
a JVM.

  Of course, it is worth noting that I don't know how this interacts
with NSJavaVirtualMachine.  We don't use that in OmniWeb since none of
our app is in Java, we don't care about the bridge -- we always use
JNI.  Hopefully, NSJVM will realize that the JVM has already been
created and not do anything.

-tim



Related mailsAuthorDate
mldelaying JVM launch time Jesse Grosjean Dec 18, 05:02
mlRe: delaying JVM launch time Timothy J. Wood Dec 18, 16:46
mlRe: delaying JVM launch time Jesse Grosjean Dec 18, 19:18