public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bucher Fabio <fabio.bucher@ntb.ch>
To: "java@gcc.gnu.org" <java@gcc.gnu.org>
Subject: create an object with cni
Date: Mon, 24 Jun 2013 12:17:00 -0000	[thread overview]
Message-ID: <17B34E365AFABC468216733E4B4CC75492AD806B@mail-server.ntb.ch> (raw)

Thank you, I can run this example and I put my code in there. Which is the right namespace to use, and which Class do I have to load with the JvInitClass()-method? Now the error message says:
Test.cc:20:29: error: expected primary-expression before »)« token
Test.cc:21:29: error: typ specification expected
Test.cc:21:29: error: Java-object test is not with new allocated
Test.cc:21:29: error: »,« or »;« expected

Do I have to load my Java-class with the JvInitClass()-method? I think yes, but how is it done the right way?


#include <gcj/cni.h>
#include "Java_with_CNI.h"
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
#include <java/lang/Throwable.h>

        int main(int argc, char *argv[]){
                using namespace java::lang;
                //using namespace ::Java_with_CNI;
                try{
                        JvCreateJavaVM(NULL);
                        JvAttachCurrentThread(NULL, NULL);
                        JvInitClass(&System::class$);
                        String *message = JvNewStringLatin1("Hello from C++");
                        System::out->println(message);


                       /* Here goes my Code */
20                      JvInitClass(Java_with_CNI);
21                      Java_with_CNI test = new Java_with_CNI::Java_with_CNI();
                        test.printHello();


                        JvDetachCurrentThread();
                }catch(Throwable *t){
                        System::err->println(JvNewStringLatin1("Unhandled Java exception:"));
                }
                //rtems_entry_point(void);
                //return 0;
        }

             reply	other threads:[~2013-06-24 12:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 12:17 Bucher Fabio [this message]
2013-06-24 12:28 ` Bryce McKinlay
  -- strict thread matches above, loose matches on Subject: below --
2013-06-24 12:54 Bucher Fabio
2013-06-24  9:37 Bucher Fabio
2013-06-24 10:27 ` Bryce McKinlay

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=17B34E365AFABC468216733E4B4CC75492AD806B@mail-server.ntb.ch \
    --to=fabio.bucher@ntb.ch \
    --cc=java@gcc.gnu.org \
    /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).