This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
CNI Invocation of Java code from C++ example fails
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-gnats at gcc dot gnu dot org, java-prs at gcc dot gnu dot org,gcc-bugs at gcc dot gnu dot org, tromey at gcc dot gnu dot org, tjmather at maxmind dot com
- Date: Tue, 28 Jan 2003 14:18:06 +0000 (GMT)
- Subject: CNI Invocation of Java code from C++ example fails
Works fine for me. It's not nice, but I can't think of a fix right now.
// test.cc
#include <gcj/cni.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
#include <java/lang/Throwable.h>
extern void _Jv_ThisExecutable(char const*);
int main(int argc, char **argv)
{
using namespace java::lang;
_Jv_ThisExecutable (argv[0]);
try
{
JvCreateJavaVM(NULL);
JvAttachCurrentThread(NULL, NULL);
String *message = JvNewStringLatin1("Hello from C++");
JvInitClass(&System::class$);
System::out->println(message);
JvDetachCurrentThread();
}
catch (Throwable *t)
{
System::err->println(JvNewStringLatin1("Unhandled Java exception:"));
t->printStackTrace();
}
}