public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* create an object with cni
@ 2013-06-24 12:54 Bucher Fabio
  0 siblings, 0 replies; 5+ messages in thread
From: Bucher Fabio @ 2013-06-24 12:54 UTC (permalink / raw)
  To: java

Thank you very much!

It works fine.

Best regards and have a nice week
Fabio Bucher

^ permalink raw reply	[flat|nested] 5+ messages in thread
* create an object with cni
@ 2013-06-24 12:17 Bucher Fabio
  2013-06-24 12:28 ` Bryce McKinlay
  0 siblings, 1 reply; 5+ messages in thread
From: Bucher Fabio @ 2013-06-24 12:17 UTC (permalink / raw)
  To: java

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;
        }

^ permalink raw reply	[flat|nested] 5+ messages in thread
* create an object with cni
@ 2013-06-24  9:37 Bucher Fabio
  2013-06-24 10:27 ` Bryce McKinlay
  0 siblings, 1 reply; 5+ messages in thread
From: Bucher Fabio @ 2013-06-24  9:37 UTC (permalink / raw)
  To: java

Hi

I just have a simple programm: One Java class, one C++ class.

Java:
public class Java_with_CNI {

    public Java_with_CNI(){
    }

    public void printHello(){
        System.out.println("Hallo Du, ich wurde durch CNI aufgerufen");
    }
}

and my C++ class:
#include <gcj/cni.h>
#include "Java_with_CNI.h"

class Hallo{
    int main(){
        Java_with_CNI test = new Java_with_CNI::Java_with_CNI();
        test.printHello();
        return 0;
    }
};


This is my first time i use C++, so I dont know whats wrong with my class. I just want to create a new Object (Java_with_CNI) and call the printHello()-method.
What is wrong with my class?

Thank you for your help and best regards
Fabio Bucher




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-24 12:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-24 12:54 create an object with cni Bucher Fabio
  -- strict thread matches above, loose matches on Subject: below --
2013-06-24 12:17 Bucher Fabio
2013-06-24 12:28 ` Bryce McKinlay
2013-06-24  9:37 Bucher Fabio
2013-06-24 10:27 ` Bryce McKinlay

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).