error porting JNI programs from Windows to Sparc Solaris 10

B

Bruce

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
 
G

Gordon Beaton

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
 
B

Bruce

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.
 
B

Bruce

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?
 
G

Gordon Beaton

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?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top