javacompilationjargcj

How do I link jar packages together with *.java files during compilation using GCJ?


I have the following files:

A.jar (containing *.class files)
B.jar (containing *.class files)
Program.java (containing Program class with main function, which depends on A.jar and B.jar)

How can I build an executable file Program using GCJ?


Solution

  • This works for me:

    gcj -c A.jar -o A.o
    gcj -c B.jar -o B.o
    gcj --main=Program --classpath=A.jar:B.jar -o Program A.o B.o Program.java