Operating System - HP-UX
1820117 Members
3089 Online
109619 Solutions
New Discussion юеВ

Re: error in calling JNI_CreateJavaVM on hpux from shared library

 
Amit_24
Occasional Contributor

error in calling JNI_CreateJavaVM on hpux from shared library

We would like to call Java methods from c++. Therefore we use JNI. The application should run on solaris, windows, aix and hp/ux. It works on windows and solaris so far, on hp/ux we have following situation: JNI_CreateJavaVM() return error on call. The error code returned is "-1"

Can anyone suggest what could possibly be wrong.
Note: The code is working in Solaris
4 REPLIES 4
Adam J Markiewicz
Trusted Contributor

Re: error in calling JNI_CreateJavaVM on hpux from shared library

Hi

My first bet is that JVM is not in $PATH. But never playd with that stuff myself.

Good luck

Adam
I do everything perfectly, except from my mistakes
Amit_24
Occasional Contributor

Re: error in calling JNI_CreateJavaVM on hpux from shared library

I checked the PATH and other env. settings. Everything seems to be fine. Can you give any other clues?
Amit_24
Occasional Contributor

Re: error in calling JNI_CreateJavaVM on hpux from shared library

I just created a simple program in HPUX whose code is written below:

#include

#include

int main(int argc, char* argv[])
{
int nError = 0;
JavaVMInitArgs sArgs;
JavaVMOption sOptions[2];
JavaVM *psMachine = (JavaVM *)0;
void *pvEnv = (void *)0;

sArgs.version = JNI_VERSION_1_2;
JNI_GetDefaultJavaVMInitArgs(&sArgs);

sOptions[0].optionString = "-Djava.compiler=NONE";
sOptions[0].optionString = "-Djava.class.path=.:/usr/local/lib";

nError = JNI_CreateJavaVM(&psMachine, &pvEnv, &sArgs);
if (nError < 0)
{
cout << "Error: ";
cout << nError;
cout << " - JNI_CreateJavaVM()\n";
} /* if */
else
{
} /* else */

return 0;
} /* main */

The error that I get in this is:

Java HotSpot(TM) Server VM warning: Disabling implicit null checks.
There was an error trying to initialize the HPI library.
Please check your installation, HotSpot does not work correctly
with any JDK 1.1.x release.
Error: -1 - JNI_CreateJavaVM()

Does anyone has any clues??
Adam J Markiewicz
Trusted Contributor

Re: error in calling JNI_CreateJavaVM on hpux from shared library

As you can imagine it is quite easy to diagnose something usefull in quite complicated system, only after simple 'not working' (as I understand this "-1").

As I understand this the problem lies n the side of Java environment rather than your code. But JVM is quite complicated application so the can be many points that are failing (maximum memory? maximum files open? problems with shared libraries linkage?)

Are you able to do any Java on the machine with the same Java engine, but started somewhat differently? Mayby the environment is configured not properly? As I imagine this the JVM itself must be started as separate process. So there must be some fork(). You make it (as I understand) from inside a shared library. Have you tried to use it directly from plain test main()? Check in the manuals for JNI for the situations where JNI_CreateJavaVM() may fail and why.

Unluckilly I'm only guessing. Someone that actually used that package by himself could find the situation easier to understand of course. But as I can see nobody was able to help yet.

Good luck
Adam
I do everything perfectly, except from my mistakes