hi,
I have a JNI program which runs correctly on windows XP jdk1.4.2_07.
But when I port the program to Sparc blade 100 Solaris 10, I get a
error when invoking the jvm. the jdk on solaris is jdk1.5.0_01. The
code is as follows:
I gdbed the program and know the code goes into JNI_VERSION_1_2 branch
and error occurs at JNI_createJavaVM. This piece of code rans correctly
on windows xp.
int InvokeJVM( JVM *jvm, const char *classpath )
{
jint res = 0;
#ifdef JNI_VERSION_1_2
JavaVMInitArgs vm_args;
JavaVMOption options[2];
char cpath[1024];
memset( cpath, 0, sizeof(cpath));
sprintf( cpath, "-Djava.class.path=%s", classpath );
options[0].optionString = cpath;
options[1].optionString = "-Xmx64m";
memset( &vm_args, 0, sizeof( vm_args ));
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 2;
vm_args.ignoreUnrecognized = JNI_FALSE;
/* Create the Java VM */
res = JNI_CreateJavaVM( &(jvm->jvm), (void**)&(jvm->jenv),
&vm_args ); // error invoking
#else
JDK1_1InitArgs vm_args;
char classpath[1024];
vm_args.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs( &vm_args );
sprintf( classpath, "%s%c%s",
vm_args.classpath, PATH_SEPARATOR, &vm_args);
vm_args.classpath = classpath;
/* Create the Java VM */
res = JNI_CreateJavaVM( &(jvm->jvm), &(jvm->jenv), &vm_args);
#endif
if ( res < 0 ) {
fprintf( stderr, "error invoking java VM with code: %d\n", res );
}
return res;
}
Any comments?
-Bruce
Gordon Beaton - 13 Mar 2006 07:31 GMT
> I have a JNI program which runs correctly on windows XP jdk1.4.2_07.
> But when I port the program to Sparc blade 100 Solaris 10, I get a
> error when invoking the jvm.
1. What error, exactly?
2. Make sure your LD_LIBRARY_PATH includes the directories
$JAVA_HOME/jre/lib/sparc and one of $JAVA_HOME/jre/lib/sparc/server
or $JAVA_HOME/jre/lib/sparc/client when you run the program.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Bruce - 13 Mar 2006 07:38 GMT
The error are as follows:
There was an error trying to initialize the HPI library.
Please check your installation, HotSpot does not work correctly
when installed in the JDK 1.2 Solaris Production Release, or
with any JDK 1.1.x release.
The return code of JNI_createJavaVM is -1.
Bruce - 13 Mar 2006 07:52 GMT
Thanks, it seems works after I set LD_LIBRARY_PATH. I noticed that
there are several copies of libjvm.so in directory
$(JDK_HOME)/jre/lib/sparc, $(JDK_HOME)/jre/lib/sparc/client,
$(JDK_HOME)/jre/lib/sparc/server.
Are they all the same? I noticed that on Windows there two jvm.dll in
the client/server dir each. But the two version are not the same. So is
the order of the dirs in LD_LIBRARY_PATH matters?
Gordon Beaton - 13 Mar 2006 08:51 GMT
> Thanks, it seems works after I set LD_LIBRARY_PATH. I noticed that
> there are several copies of libjvm.so in directory
[quoted text clipped - 4 lines]
> in the client/server dir each. But the two version are not the same.
> So is the order of the dirs in LD_LIBRARY_PATH matters?
I suggested that you include *one* of the server or client paths.
These correspond to the java -client and -server options, described
here:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/java.html
http://java.sun.com/j2se/1.5.0/docs/guide/vm/server-class.html
If you specify both paths I assume (guess) that you get the first one
found, which may not be what you want.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e