Index of /~costello/Linux_Invoke

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[TXT]Prog.java04-Jun-2003 11:39 582  
[   ]Makefile04-Jun-2003 12:54 792  
[TXT]invoke.c04-Jun-2003 11:39 2.5K 

 * README.txt
 * David Costello,,  4 Jun 2003
 * Time-stamp: <2003-06-04 13:08:29 costello>
 * How to call java via jni under linux example 

This is a small example of how to call java from C under Linux.
The gcc compiler does not offer the -R flag which writes the 
LD_RUN_PATH into the binary so in this example use

make run

I guess in a real program you'll have to muck with LD_LIBRARY_PATH
so the program can find it's dynamic libraries via wrappers or
ENVIRONMENT variables or whatever.

Be advised I have experienced some memory leaking using JNI from 
JDK1.3 under solaris.  I have not tested extensibly JNI under
Linux or JNI with JDK1.4 or above.
tested using:
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)

included example files:

invoke.c -- C program that instantiates a java VM and makes calls 
            to a java class (Prog.class) -- the simple java program called from C

Makefile -- to build and run the example.