This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
compile against library needs classes?!
- From: gcj at stuellenberg dot de
- To: java at gcc dot gnu dot org
- Date: Thu, 11 Sep 2003 10:16:19 +0200 (CEST)
- Subject: compile against library needs classes?!
Hello all,
I hope, I don't bother you with an already frequently asked question,
but I've not found an answer...
How is it possible to compile a native executable with gcj from a
.java file with an reference to another (but already compiled as an
DSO/static lib) Java class?
To speak, let me give the following example:
<<<---HW_lib.java--->>>
public class HW_lib {
public static int foo = 0;
}
<<<----------------->>>
<<<---HelloWorld.java--->>>
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Test: "+HW_lib.foo);
}
}
<<<--------------------->>>
Now I do
gcj -shared HW_lib.java -o libhw.so
and get a shared library.
Now I want to do
gcj --main=HelloWorld -o HelloWorld HelloWorld.java libhw.so
but that does not work:
HelloWorld.java: In class `HelloWorld':
HelloWorld.java: In method `HelloWorld.main(java.lang.String[])':
HelloWorld.java:3: error: Undefined variable or class name: `HW_lib.foo'.
System.out.println("Test: "+HW_lib.foo);
^
1 error
If I add the HW_lib.[class|java] to the classpath, everything works.
What I'm doing wrong here, or is it impossible to do so?
Regards,
Christian