Loading Libraries
Lars Andersen
lars@rimfaxe.com
Sun Jun 15 09:17:00 GMT 2003
On Sun, 2003-06-15 at 00:03, steve wrote:
> Lars,
>
> How did you create the so?
> Anyone try this with 3.4, to confim that this is not my problem?
/usr/local/bin/gcj -shared Hello.java -o libHello.so
I have to include /usr/local/lib in LD_LIBRARY_PATH to make it work,
'cause thats where the 3.3 lives.
I changed app.java to :
>>>>>>>
public class app
{
public static void main(String[] args)
{
try {
System.load("/home/lars/loadlib/libHello.so");
Class Klass1 = Class.forName("Hello");
String
s1=(String)Klass1.getMethod("HelloString",null).invoke(null,null);
System.out.println("String from class 1 " + s1 + "\n");
} catch (Exception e) {
System.out.println("ERROR \n\t" +e);
}
}
}
<<<<<<<<
and compiled it, vanilla style :
/usr/local/bin/gcj --main=app app.java -o app
Execute app and get :
String from class 1 V1 Hello
/Lars Andersen
More information about the Java
mailing list