This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: create an object with cni
- From: Bryce McKinlay <bmckinlay at gmail dot com>
- To: "java at gcc dot gnu dot org" <java at gcc dot gnu dot org>
- Cc: Bucher Fabio <fabio dot bucher at ntb dot ch>
- Date: Mon, 24 Jun 2013 13:28:53 +0100
- Subject: Re: create an object with cni
- References: <17B34E365AFABC468216733E4B4CC75492AD806B at mail-server dot ntb dot ch>
On Mon, Jun 24, 2013 at 1:17 PM, Bucher Fabio <fabio.bucher@ntb.ch> wrote:
> 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?
The namespace corresponds directly to the package name in Java. e.g.
"java.util" becomes "java::util". If your java class has no package
name then you don't need any namespace.
> 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?
Actually, no, you don't need to bother with JvInitClass in this case,
because calling "new" will ensure that it is initialised
automatically. The example only needs the JvInitClass() call because
it is accessing a static Java variable, System.out.
The correct syntax to reference your class would be:
&Java_with_CNI::class$ (This is the CNI equivalent of
"Java_with_CNI.class" in Java.)
Bryce