This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
more doc needed?
- From: Nic Ferrier <nferrier at tapsellferrier dot co dot uk>
- To: java at gcc dot gnu dot org
- Date: 22 Jul 2002 23:08:39 +0100
- Subject: more doc needed?
I've just come to write a bit of native code and realised that I
don't actually know how to do the integration and it doesn't seem to
be documented anywhere.
I think we need something like the following in the CNI manual, it's
an example of how to do Java/C++ CNI integration.
>>>> example >>>>>
1. save the following file as Test.java:
public class Test
{
private native void native0 ();
public void nonNative ()
{
native0();
}
}
2. Then compile it:
gcj -C -d . Test.java
and generate the header:
gcjh --classpath . Test
3. edit the Test.cc file and fill in the blanks.
4. Now compile the Test.cc file ??????
5. And now cause Test.java to load Test.cc? eg:
public class Test
{
static
{
System.loadLibrary("Test");
}
private native void native0 ();
public void nonNative ()
{
native0();
}
}
Be sure to set LD_LIBRARY_PATH to the lib location of Test when
running the java code.
<<<<
If someone tells me the sort of g++ line I need I'll flesh this out and
add a section to the CNI manual.
Nic