public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bryce McKinlay <bmckinlay@gmail.com>
To: Vaijayanthi Mala Suresh <vaijayanthimalas@gmail.com>
Cc: java@gcc.gnu.org
Subject: Re: Invoking JNI function using gcj
Date: Wed, 27 May 2009 09:48:00 -0000	[thread overview]
Message-ID: <7230133d0905270248m20e28465oc982a1ca052c2c99@mail.gmail.com> (raw)
In-Reply-To: <6f1633170905270134m29a652d6g270a7fb97833bf05@mail.gmail.com>

On Wed, May 27, 2009 at 9:34 AM, Vaijayanthi Mala Suresh
<vaijayanthimalas@gmail.com> 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

      parent reply	other threads:[~2009-05-27  9:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-27  8:34 Vaijayanthi Mala Suresh
2009-05-27  8:48 ` Andrew Haley
2009-05-27  9:48 ` Bryce McKinlay [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7230133d0905270248m20e28465oc982a1ca052c2c99@mail.gmail.com \
    --to=bmckinlay@gmail.com \
    --cc=java@gcc.gnu.org \
    --cc=vaijayanthimalas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).