calling java from c++

Bryce McKinlay bryce@waitaki.otago.ac.nz
Wed Mar 27 15:30:00 GMT 2002


akos.szalay@sophos.com wrote:
>I'm trying to call java from c++ using gcj.
>I thought, that the following code should work, but it coredumps
>(segmentation fault) on new.
>Any idea what's wrong with it ? (any workaround for this problem ?)
>I'm running redhat linux 7.1
>
You must call JvCreateJavaVM() before making any calls to Java code from 
an application with a C/C++ "main" method. eg:
--- orig/javatest.cpp Thu Mar 28 11:28:23 2002
+++ javatest.cpp Thu Mar 28 11:26:26 2002
@@ -7,6 +7,7 @@
 {
 printf("Starting...\n");
 
+ JvCreateJavaVM(NULL);
 otherclass *ttt = new otherclass();
 
 printf("Otherclass created (%p)\n",ttt);
Note that this only works with GCJ 3.1 and up.
regards
Bryce.


More information about the Java mailing list

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