Lisp HUG Maillist Archive

Java interface issues

After loading the interface with:

    (require "java-interface")

I invoke the following:

    (lw-ji:import-java-class-definitions "java.io.File")

But then, I get:

Error: Foreign function LW-JI::GET-SINGLE-JAVA-VM trying to call to unresolved external function "JNI_GetCreatedJavaVMs".
  1 (abort) Return to level 0.
  2 Return to top loop level 0.

What causes that?

--
Rommel Martinez
https://ebzzry.io

Re: Java interface issues

You need to initialize the java interface first, by telling LispWorks the location of “libjvm.dll” (.so, .dylib) in JRE/JDK. Consider putting the following scripts in ~/.lispworks:

(defparameter *jdk8-library-path*
  "/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server/libjvm.dylib")

(defun load-java8 (&optional class-paths)
  (let ((lispcalls (namestring (lispworks-file "etc/lispcalls.jar"))))
    (funcall
      (intern "INIT-JAVA-INTERFACE" "LW-JI")
      :jvm-library-path *jdk8-library-path*
      :java-class-path (if class-paths
                           (format nil "~S:~S" lispcalls class-paths)
                           lispcalls))))

It also gives you possibility to load third-party JARs.  You can even duplicate above scripts to selectively load other JDK versions (but at any time there can only be one in use).

Hope this helps,

Chun

Il giorno 06 lug 2018, alle ore 11:44, Rommel MARTINEZ <ebzzry@ebzzry.io> ha scritto:

After loading the interface with:

    (require "java-interface")

I invoke the following:

    (lw-ji:import-java-class-definitions "java.io.File")

But then, I get:

Error: Foreign function LW-JI::GET-SINGLE-JAVA-VM trying to call to unresolved external function "JNI_GetCreatedJavaVMs".
  1 (abort) Return to level 0.
  2 Return to top loop level 0.

What causes that?

--
Rommel Martinez
https://ebzzry.io

Re: Java interface issues

Thanks, Chun Tian!

On Fri, Jul 6, 2018 at 7:55 PM, Chun Tian (binghe) <binghe.lisp@gmail.com> wrote:
You need to initialize the java interface first, by telling LispWorks the location of “libjvm.dll” (.so, .dylib) in JRE/JDK. Consider putting the following scripts in ~/.lispworks:

(defparameter *jdk8-library-path*
  "/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server/libjvm.dylib")

(defun load-java8 (&optional class-paths)
  (let ((lispcalls (namestring (lispworks-file "etc/lispcalls.jar"))))
    (funcall
      (intern "INIT-JAVA-INTERFACE" "LW-JI")
      :jvm-library-path *jdk8-library-path*
      :java-class-path (if class-paths
                           (format nil "~S:~S" lispcalls class-paths)
                           lispcalls))))

It also gives you possibility to load third-party JARs.  You can even duplicate above scripts to selectively load other JDK versions (but at any time there can only be one in use).

Hope this helps,

Chun

Il giorno 06 lug 2018, alle ore 11:44, Rommel MARTINEZ <ebzzry@ebzzry.io> ha scritto:

After loading the interface with:

    (require "java-interface")

I invoke the following:

    (lw-ji:import-java-class-definitions "java.io.File")

But then, I get:

Error: Foreign function LW-JI::GET-SINGLE-JAVA-VM trying to call to unresolved external function "JNI_GetCreatedJavaVMs".
  1 (abort) Return to level 0.
  2 Return to top loop level 0.

What causes that?

--
Rommel Martinez
https://ebzzry.io




--
Rommel Martinez
https://ebzzry.io
Updated at: 2020-12-10 08:29 UTC