Re: Invoking JNI function using gcj
Bryce McKinlay <[email protected]>
| Newsgroups | gmane.comp.gcc.java.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, May 27, 2009 at 9:34 AM, Vaijayanthi Mala Suresh <[email protected]> wrote: > I have compiled it with gcj as given below > gcj -c -fjni HelloWorld.java > gcj -C HelloWorld.java > gcjh HelloWorld > gcjh -jni HelloWorld -o HelloNative.h > gcjh -stubs -jni HelloWorld > g++ -I. -c HelloWorld.c natHelloWorld.o > gcj -shared natHelloWorld.o -o libHelloWorld.so > > Copied the .so file into the folder as /lib and it set in LD_LIBRARY_PATH. > > I have a cppstartup.cpp which does the JVM Initialization and has > invokes HelloWorld as given below > > #include "HelloWorld.h" > > using namespace java::lang; > > try > { > JvCreateJavaVM(NULL); > JvAttachCurrentThread(NULL, NULL); > > String *message = JvNewStringLatin1("Hello from C++"); > JvInitClass(&System::class$); > System::out->println(message); It looks like you're confusing JNI with CNI. You mentioned JNI and used the "-jni" option to gcjh, but the C++ code you provided appears to be CNI. Bryce