Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3FFF1AB4.4010609@nationwide.com> Date: Fri, 09 Jan 2004 16:18:44 -0500 From: Moy Easwaran User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Problem with JVM 1.4.2 on Cygwin 1.5.5-1 on XP and 2000 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit 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 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 My steps and files are as follows: $ dlltool --input-def jvm.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a $ 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 AT 12 JNI_GetDefaultJavaVMInitArgs AT 4 JNI_GetCreatedJavaVMs AT 12 $ 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 #include 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"; 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; } -- 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/