newbie question: need help linking

Prabhakar, Vijay (IT)
Wed Dec 1 15:34:00 GMT 2004

Hmm, what about a native method that's written as part of a Java class
that's compiled with gcj.  Can that be called from a .class file?  I was
thinking about writing a class for wrapping and unwrapping primitives
when communicating between C++ and Java.  In other words, I was hoping
to have a class converts RawData objects which are actually arrays (or
vectors/other STL datastructures) of C++ primitives and returns arrays
of Java primitives.  Would I be better off writing a C++ template that
converts C++ primitives into j<primitive> arrays so that it can
communicate with the Java code?


-----Original Message-----
From: [] On Behalf
Of Andrew Haley
Sent: Wednesday, December 01, 2004 9:28 AM
To: Prabhakar, Vijay (IT)
Subject: Re: newbie question: need help linking

Prabhakar, Vijay (IT) writes:
 > Hi, I'm having a few problems with which I was hoping someone could
 > me out.  I'm using GCJ 3.2.3-42.  I'm not sure if this is possible,
 > which might explain why I can't get this system running.  I have a
 > program that is written in C++ and it uses several libraries.  I'm
 > trying to change one of the libraries to Java while leaving a C++
 > interface to it so the original program can continue running without
 > changes.  
 > So essentially, I have a C++ class with a main, calling another C++
 > class which calls a Java class.  So I compile my Java class with GCJ
 > produce the C++ header file.  Both C++ classes compile fine as well.
 > However, I cannot get the program to link.  I can get it to link if I
 > compile the Java source file to an object file, but not a class file.

Right: that's what gcj does.  There is, at present, no easy way to
call CNI code directly from a .class file.  It can be done indirectly,
but that's another matter.

NOTICE: If received in error, please destroy and notify sender.  Sender does not waive confidentiality or privilege, and use is prohibited. 

More information about the Java mailing list