Linking Java JNI application: _JNI_CreatedJavaVMs unresolved

I am migrating a Java JNI application from Linux (where it works under JDK1.6) to MacOSX 10.5.6 with JDK1.5. The link step fails:
reticuli:ims/ARC/java wmtaylor% ./compileIMSGUI.csh
Undefined symbols:
"_JNI_GetCreatedJavaVMs", referenced from:
ims5_1_monitor_nomain(int, char**)in ims5_1_monitor_nomain.o
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

The compile script follows: ($JAVA_HOME = /usr)

$JAVA_HOME/bin/javac -Xlint -sourcepath $IMS_HOME/src -classpath $IMS_HOME/classes:$IMS_HOME/lib/plot.jar:$IMS_HOME/lib/Jama-1.0.2.jar -d $IMS_HOME/classes src/gov/nasa/arc/ims/gui/*.java src/gov/nasa/arc/ims/utils/*.java src/gov/nasa/arc/ims/commandLine/*.java

#

1. JNI processing

$JAVA_HOME/bin/javah -jni -classpath $IMS_HOME/classes -o ../cpp/src/ims5.1/RunMonitor.h gov.nasa.arc.ims.gui.RunMonitor

1. create .so library file

if (`uname` == "Linux") then

gcc -c -g -fPIC -Wno-deprecated -o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_jni.o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_jni.cpp -I $JAVA_HOME/include -I $JAVA_HOME/include/linux

gcc -fPIC -Wno-deprecated -c -o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_nomain.o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_nomain.cpp -I $JAVA_HOME/include -I $JAVA_HOME/include/linux

else
gcc -c -g -fPIC -Wno-deprecated -o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_jni.o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_jni.cpp -I /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers

gcc -fPIC -Wno-deprecated -c -o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_nomain.o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_nomain.cpp -I /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers
endif

gcc -shared -o $IMS_HOME/../cpp/src/ims5.1/libims5_1_monitor_jni.so $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_jni.o $IMS_HOME/../cpp/src/ims5.1/ims5_1_monitor_nomain.o -lm -lstdc++ Thanks for any assistance,
Wm

PowerPC G5, Mac OS X (10.5.6), Dual 1.8 GHz

Posted on Mar 11, 2009 2:56 PM

Reply
2 replies

Mar 12, 2009 4:57 PM in response to wm1087

JNICreatedJavaVms is probably in some obscure library file, which I did not spent much time attempting to find. So I changed my design: instead of trying to connect to the VM and hence the JNI env, from my C code (ims5 1_monitornomain.cpp), I passed the VM as an argument to the C code and used
JNIEnv* env;
jvm->AttachCurrentThread((void**)&env, NULL);
to get env.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Linking Java JNI application: _JNI_CreatedJavaVMs unresolved

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.