This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]