This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

create an object with cni


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]