Reputation: 4578
We have this native application which starts a jvm within its process, and uses JNI to call Java code.
We put the location of the jvm.dll in the path (this is on windows) so that it can be loaded, and we've noticed that when we use the 'client' directory, everything works fine, but when compiled as 32-bit, when we use the 'server' directory, JNI_CreateJavaVM() fails with a return value of -4.
As far as I know, both client and server versions of the JVM should work, so what's going on?
Upvotes: 0
Views: 1338
Reputation: 70909
Looks suspiciously like you're creating a JVM that can't be launched because it is configured to use more memory than is available.
#define JNI_OK 0
#define JNI_ERR (-1)
#define JNI_EDETACHED (-2)
#define JNI_EVERSION (-3)
#define JNI_ENOMEM (-4)
#define JNI_EEXIST (-5)
#define JNI_EINVAL (-6)
Of course, other interpretations are available; but, would you check you system's free memory, the configuration parameters, and the maximum process size (if you are using an older version of windows). I think that this might be the problem you are encountering.
It would also explain the "works but doesn't work now" issues, as probably at the time of failure, the system didn't have enough free memory to commit to the JVM (which grabs all of its memory up front, before running). Perhaps you server version asks for "just enough" to push the limit.
Upvotes: 1