From: ·············@my-dejanews.com
Subject: Call JAVA VM from Lisp
Date: 
Message-ID: <7f51hm$m08$1@nnrp1.dejanews.com>
Hi,

I want to start a JAVA-VM from Lisp (Allegro CL 5.0 on Linux). Therefore I
wrote a small C-routine (it's nearly SUNs invoke.c, see below), compile it
as a ".so"-file, load that into lisp and define a foreign-function "foo"
via (defforeign ...).

But when I call (foo), it terminates with
Can't find class java.lang.System
Can't create Java VM

When I call the C-function from a C-main-function, all works fine (it has
the same classpath, the same LD_LIBRARY_PATH). What could go wrong here?

Martin

8<-----------------------------------------------------------------------------

void foo() {
    JNIEnv *env;
    JavaVM *jvm;
    JDK1_1InitArgs vm_args;
    jint res;
    jclass cls;
    jmethodID mid;
    jstring jstr;
    jobjectArray args;
    char classpath[1024];


    /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
    vm_args.version = 0x00010001;

    JNI_GetDefaultJavaVMInitArgs(&vm_args);

    /* Append USER_CLASSPATH to the end of default system class path */
    sprintf(classpath, "%s%c%s:/usr/lib/jdk1.1.7/lib/classes.zip",
            vm_args.classpath, PATH_SEPARATOR, USER_CLASSPATH);
    vm_args.classpath = classpath;

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

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
From: Jason Trenouth
Subject: Re: Call JAVA VM from Lisp
Date: 
Message-ID: <373a1be0.331162312@newshost>
On Thu, 15 Apr 1999 15:44:57 GMT, ·············@my-dejanews.com wrote:

> Hi,
> 
> I want to start a JAVA-VM from Lisp (Allegro CL 5.0 on Linux). Therefore I
> wrote a small C-routine (it's nearly SUNs invoke.c, see below), compile it
> as a ".so"-file, load that into lisp and define a foreign-function "foo"
> via (defforeign ...).
> 
> But when I call (foo), it terminates with
> Can't find class java.lang.System
> Can't create Java VM
> 
> When I call the C-function from a C-main-function, all works fine (it has
> the same classpath, the same LD_LIBRARY_PATH). What could go wrong here?
> 

If you want to get Java and Common Lisp cooperating then why not use CORBA?
Harlequin, Franz, and Xerox, have CORBA support for Common Lisp. There is
loads of support for CORBA and Java.

__Jason