Invoking a JVM from C with diablo-jdk

some one devnullaccount at yahoo.se
Wed Apr 28 08:15:29 PDT 2004


Hi!

I'm trying to invoke a JVM from a C program (using
FreeBSD 4.8-RELEASE w/ cvsup:ed ports tree) and
whatever I do, it tries to use native_threads even
though the diablo-jdk does not have these. I've tried
with the shell variables shown below, but I still fail
in the exact same way.
--------------------------
Here's some shell output:

shell> java -version
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition
(build diablo-1.3.1-0)
Classic VM (build diablo-1.3.1-0, green threads,
nojit)
shell> echo $PATH
/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/X11R6/bin:/usr/local/diablo-jdk1.3.1/bin/
shell> echo $LD_LIBRARY_PATH
/usr/local/diablo-jdk1.3.1/jre/lib/i386:/usr/local/diablo-jdk1.3.1/jre/lib/i386/classic:/usr/local/diablo-jdk1.3.1/jre/lib/i386/green_threads
shell> echo $THREADS_TYPE
green_threads
shell> gmake clean invoke
rm invoke
cc -I/usr/local/diablo-jdk1.3.1/include/
-I/usr/local/diablo-jdk1.3.1/include/freebsd/
-L/usr/local/diablo-jdk1.3.1/jre/lib/i386
-L/usr/local/diablo-jdk1.3.1/jre/lib/i386/classic
-L/usr/local/diablo-jdk1.3.1/jre/lib/i386/green_threads
-ljava -lverify -ljvm -lhpi -o invoke invoke.c
shell> ./invoke 
Cannot open
"/usr/local/diablo-jdk1.3.1/jre/lib/i386/native_threads/libhpi.so"Can't
create Java VM
Exit 1

Native threads? No, I said green threads! :)
-------------------------

This is the "invoke.c" file that I'm
compiling/running:

#include <jni.h>
main() {
    JNIEnv *env;
    JavaVM *jvm;
    JavaVMInitAr vm_args;
    jint res;

    vm_args.version = JNI_VERSION_1_2;
    JNI_GetDefaultJavaVMInitArgs(&vm_args);

    /* Create the Java VM */
    res = JNI_CreateJavaVM(&jvm,(void
**)&env,&vm_args);
    if (res < 0) {
        fprintf(stderr, "Can't create Java VM\n");
        exit(1);
    }
}

---------

Doesn't this work with diablo? If so, what jdk port
should I use to get it to work?

Any help would be greatly appreciated.

/krs


Höstrusk och grå moln - köp en resa till solen på Yahoo! Resor på adressen http://se.docs.yahoo.com/travel/index.html


More information about the freebsd-java mailing list