Java dynamic init failed.

I'm attempting to get the CobolCallingJava example for ACUCOBOL-GT version 8.1.3.1 working. When running the example, I get the following error for each occurrence of CALL C$"JAVA":

Java dynamic init failed.

It is the same error message as described in the following Wiki article, but in our case we're running this test in Windows 7.

community.microfocus.com/.../6320.c-java-gives-error-java-dynamic-init-failed.aspx

The JDK installed on my PC is jdk1.7.0_17.

The Java-related settings in our COBOL config file are as follows:

PRELOAD_JAVA_LIBRARY=1
JAVA_LIBRARY_NAME="C:\Program Files\Java\jdk1.7.0_17\jre\bin\server\jvm.dll"
JAVA_OPTIONS=-Djava.class.path=R:\Topps\BIN\CVM.jar;.;

My CLASSPATH environment variable = R:\Topps\BIN\CVM.jar;.;

My PATH environment variable includes the Java bin directory, as well as the directory containing jvm.dll, i.e.,

....;C:\Program Files\Java\jdk1.7.0_17\jre\bin;C:\Program Files\Java\jdk1.7.0_17\jre\bin\server;....

My LD_LIBRARY_PATH environment variable = R:\Topps\BIN

The file R:\Topps\BIN\CVM.jar does exist, as does "C:\Program Files\Java\jdk1.7.0_17\jre\bin\server\jvm.dll".

There are no errors when compiling either the Java or the COBOL programs in the example. However, I do get "Java dynamic init failed" at runtime.

What am I missing? Thanks!

  • Verified Answer

    A few things to look for:

    • Make sure your Acu runtime and the JVM are either both 32-bit or both 64-bit, not one of each.  You can't mix them.
    • In your JAVA_LIBRARY_NAME variable (in the config file), remove the double-quotes.
    • You have CVM.jar in your CLASSPATH, but not sure why you need it.  It's normally only used for Java-calling-COBOL, not the other way around.  But it doesn't hurt to have it there.
    • I don't think what's in your PATH has any bearing on this.
    • LD_LIBRARY_PATH is only meaningful on Unix and Linux systems.  It won't have any effect on Windows.

    I've just done a simple test on my Windows 7 64-bit system and got it working - with the quotes removed from JAVA_LIBRARY_NAME.  I'm using JRE 1.7.0_25, and Acu 9.1.2 (both 32-bit).  Since I only have a JRE (not a JDK), my Java library is in the client directory (C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll on my system).  You might need to try with the jvm.dll under client instead of server.

  • I'll try your recommendations out, and will report back with the outcome.

    My hunch is that you've identified the problem. Our Acu installation is 32-bit, and the path to my jvm.dll indicates 64-bit.

    Thanks!

  • That was it! The only change required was to use this line in the runtime configuration file:

    JAVA_LIBRARY_NAME=C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll

  • That was it! The only change required was to use this line in the runtime configuration file:

    JAVA_LIBRARY_NAME=C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll

  • That was it! The only change required was to use this line in the runtime configuration file:

    JAVA_LIBRARY_NAME=C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll