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

Lars Andersen lars@rimfaxe.com
Wed Oct 22 14:41:00 GMT 2003


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


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /