This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: calling java from c++
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: akos dot szalay at sophos dot com
- Cc: java at gcc dot gnu dot org
- Date: Thu, 28 Mar 2002 11:29:23 +1200
- Subject: Re: calling java from c++
- References: <OF57E05FFE.F7428CC2-ON80256B89.0044FDEA@uk.sophos>
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.