I use gcj (Cygwin version) to compile 2 java files
$ gcj --version gcj (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Here's my 2 java files:
$ cat MyClass.java
public class MyClass {
public MyClass() {
System.out.println("Hello, MyClass");
}
}
$ cat HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
MyClass myclass = new MyClass();
System.out.println("Hello, World");
}
}
I'm able to execute the code in HelloWorld with
$ gcj.exe -o hello --main=HelloWorld --classpath=. HelloWorld.java MyClass.java
I would like to compile them separatly like
gcj.exe -C MyClass.java
then
gcj.exe --main=HelloWorld --classpath=. HelloWorld.java
The problem is that I get
/tmp/ccKwa7F4.o: In function '_ZN10HelloWorld4mainEP6JArrayIPN4java4lang6StringEE':
/home/lucm/HelloWorld.java:3: undefined reference to `MyClass::class$'
/home/lucm/HelloWorld.java:3: undefined reference to `MyClass::MyClass()'
collect2: ld returned 1 exit status