Problem with JVM 1.4.2 on Cygwin 1.5.5-1 on XP and 2000

Igor Pechtchanski pechtcha@cs.nyu.edu
Fri Jan 9 21:40:00 GMT 2004


On Fri, 9 Jan 2004, Moy Easwaran wrote:
> I'm trying to run HelloWorld.java on a JVM invoked from C. I'm using
> the basic setup in David Caldwell's excellent how-to at
> <http://www.inonit.com/cygwin/jni/invocationApi/> et seq.
>> It works fine on WinNT 4.0 and WinXP Home, but dies on WinXP Pro and
> Win2000.
>> There's not really much of a trail I can provide. I get a message-box
> saying: "jvm.exe has encountered a problem and needs to close. We are
> sorry for the invonvenience."
>> It dies on JNI_CreateJavaVM with the 1.4.1 SDK. In 1.4.2,
> JNI_CreateJavaVM always returns -1 (and so FindClass can't run).
>> The Windows event log says:
> "Faulting application jvm.exe [my executable], version 0.0.0.0,
> faulting module jvm.dll, version 0.0.0.0, fault address 0x000a9d63.
> Application Failure jvm.exe 0.0.0.0 in jvm.dll 0.0.0.0 at offset
> 000a9d63.."
>> Any suggestions on where to look or what to look for? Help!
>> Thanks much,
>> Moy

Moy,
Technically, since you're using -mno-cygwin, this is not a Cygwin problem.
You could probably get better answers on the MinGW-users list (see
<http://mingw.org/>). However, I have a couple of guesses inline below
that might be helpful.
> My steps and files are as follows:
>> $ dlltool --input-def jvm.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a

Where is this jvm.dll coming from?
> $ gcc -Wall -mno-cygwin -o jvm.exe -I/cygdrive/c/j2sdk1.4.1_06/include -I/cygdrive/c/j2sdk1.4.1_06/include/win32 jvm.c -L. -ljvm
> $ cat jvm.def
> EXPORTS
> JNI_CreateJavaVM@12
> JNI_GetDefaultJavaVMInitArgs@4
> JNI_GetCreatedJavaVMs@12

Are you sure you got the right argument patterns here (i.e., numbers after
the '@' sign)? That may be one source of the problem.
> $ cat HelloWorld.java
> public class HelloWorld
> {
> public static void main (String args [])
> {
> System.out.println ("Hello, world!");
> }
> }
>> $ cat jvm.c # this is basically the invoke.c example on inonit.com
> #include <stdio.h>
> #include <jni.h>
>> JNIEnv* create_vm() {
> JavaVM* jvm;
> JNIEnv* env;
> JavaVMInitArgs args;
> JavaVMOption options[1];
> int res;
>> /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */
> args.version = JNI_VERSION_1_2;
> args.nOptions = 1;
> options[0].optionString = "-Djava.class.path=c:\\test";

Shouldn't this also contain a pointer to the default class libraries?
> args.options = options;
> args.ignoreUnrecognized = JNI_TRUE;
>> printf ("about to call CreateJavaVM.\n");
> res = JNI_CreateJavaVM(&jvm, (void **)&env, &args);
> printf ("CreateJavaVM returned [%d].\n", res);
> return env;
> }
>> void invoke_class(JNIEnv* env) {
> jclass helloWorldClass;
> jmethodID mainMethod;
> jobjectArray applicationArgs;
> jstring applicationArg0;
>> printf ("step 2...\n");
> helloWorldClass = (*env)->FindClass(env, "HelloWorld");
>> printf ("step 3...\n");
> mainMethod = (*env)->GetStaticMethodID(env, helloWorldClass, "main", "([Ljava/lang/String;)V");
>> printf ("step 4...\n");
> applicationArgs = (*env)->NewObjectArray(env, 1, (*env)->FindClass(env, "java/lang/String"), NULL);
> applicationArg0 = (*env)->NewStringUTF(env, "From-C-program");
> // (*env)->SetObjectArrayElement(env, applicationArgs, 0, applicationArg0);
>> printf ("step 5...\n");
> (*env)->CallStaticVoidMethod(env, helloWorldClass, mainMethod, applicationArgs);
> }
>> int main(int argc, char **argv) {
> JNIEnv* env = create_vm();
> printf ("step 1 done...\n");
> invoke_class( env );
> return 0;
> }

HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
 |\ _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_		igor@watson.ibm.com
 |,4- ) )-,_. ,\ ( `'-'		Igor Pechtchanski, Ph.D.
 '---''(_/--' `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /