C++ and GCJ

Szasz Pal spacegcc@email.ro
Wed Mar 5 10:18:00 GMT 2003


Hi!

I just started to work with GCJ.
I made a class (test):
--------8<--------
import java.io.*;

public class test
{
    static public void main(String args[]){
        System.out.println("Hello!");
    }
    int sqr(int num)
    {
        System.out.println("Hello from sqr!");  // !!
        return num*num;
    }
}
--------8<--------
and a main.cxx file:
--------8<--------
#include "test.h"
#include <stdio.h>

int main()
{
    printf("IN main!\n");
    int a=8;
    printf("a=%d\n",a);
    test tmp;
    int b=tmp->sqr(a);
    printf("b=%d\n",b);
    return 0;
}
--------8<--------
Compile the test.java with gcj to .o, make a .class and .h 
so I can access it from cxx, compile the main.cxx and link them
both (with g++)
If the line marked with "// !!" is missing, it works well,
but with it (System.out.println....) it gives me a segmentation fault.

Why ?
Well, first of all, this is a good way to combine C++ and Java ?
I need the both, because this way I can develop with rhide,
and I can use it's the debugging facility.

Szasz Pal


______________________________________________________________________
Do you want a free e-mail for life ? Get it at http://www.email.ro/



More information about the Java mailing list