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]

Re: can't get a simple package example to compile with gcj


Christopher Marshall wrote:

I am having trouble getting a very simple java program to compile with gcj in which the main java file invokes a constructor on a class defined in a package.

I have the CLASSPATH variable set to '.' (the current directory).

Here's the main program, which is in the directory I am invoking gcj from:

// pkgtest.java
import java.io.*;
import A.*;

public class pkgtest {
  public static void main(String args[]){
     A.B x= new A.B(3);
     System.out.println(x.x);
  }
}

And in a subdirectory A, I put B.java:

// A/B.java
package A;

public class B{
  int x;
  public B(int i){
     x= i;
  }
}

I run gcj like this:

gcj --main=pkgtest -o pkgtest pkgtest.java




compile pkgtest.java and B.java in one line :


gcj --main=pkgtest -o pkgtest pkgtest.java B.java

... or for larger projects compile single or groups of java files into object files, and link them together :


gcj -c pkgtest.java -o pkgtest.o gcj -c B.java -o B.o gcj --main=pkgtest -o pkgtest pkgtest.o B.o


/Lars Andersen






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