C++ and GCJ

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


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

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

int main()
    printf("IN main!\n");
    int a=8;
    test tmp;
    int b=tmp->sqr(a);
    return 0;
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