Call Java Programs from Julia
You are attempting to call Java methods without initialising the JVM. Call JavaCall.init(...)
first.
The JVM dynamic library cannot be found. It is called libjvm.so
, libjvm.dylib
or jvm.dll
depending on your system. Check that you have JAVA_HOME
environment variable defined. If you do, verify the search logic in the code, and please file a pull request with an amemded version that can find your library. As a workaround, you can set the JAVA_LIB
environment variable to point to the location of the library file.
Upon initialising JavaCall on OSX, you get an immediate segfault message, while execution carries on normally.
signal (11): Segmentation fault: 11
unknown function (ip: 0x31960c2b4)
This message is usually benign. It is due to the way the JVM uses signals for its regular operations. Julia on OSX installs a signal handler, which generates the above message. However, since the signal is eventually caught and handled by the JVM, execution carries on normally. If the message troubles you for any reason, please start julia with the --handle-signals=no
option. In this case, Julia’s signal handler will be disabled, and you will no longer see the above message. However, this may cause issues with handling ^C
in Julia programs.
References:
Unfortunately, Java on the Mac has a known bug, wherein attempting to load a JVM via JNI fails unless the old OSX system Java 6 libraries are installed on the machine. This is strictly not necessary to run any Java programs, but is required due to a bug. This is scheduled to be fixed only in Java 9. In the meantime, the only option is to download and install the Apple Java 6 libraries from this url: https://support.apple.com/kb/dl1572?locale=en_US
Make sure the signature of the method is what you expect it to be. See listmethods()
function from Reflection API.
Make sure JavaObject{T}
has an expected type parameter T
. To call a Java method, jcall
uses T
as the name of a class to call the method on, even if actual object class is different. See Inspecting classes section from Reflection API.