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: Bucher Fabio <fabio dot bucher at ntb dot ch>
- Cc: "java at gcc dot gnu dot org" <java at gcc dot gnu dot org>
- Date: Mon, 24 Jun 2013 11:27:34 +0100
- Subject: Re: create an object with cni
- References: <17B34E365AFABC468216733E4B4CC75492AD7EF3 at mail-server dot ntb dot ch>
Fabio,
You need to initialise Java by calling "JvCreateJavaVM(NULL);" before
making calls from C++ into Java code.
See the CNI documentation (§ 11.16.2) for a complete example:
http://gcc.gnu.org/onlinedocs/gcj/Invocation.html#Invocation
Bryce
On Mon, Jun 24, 2013 at 10:37 AM, Bucher Fabio <fabio.bucher@ntb.ch> wrote:
> 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
>
>
>
>