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]

CLASSPATH problems


Hi.

Platform: RedHat 7.1 on an Intel box.

Relevant RPMs:
  libgcj-2.96-24
  libgcj-devel-2.96-24
  gcc-java-2.96-85

I'm having some problems getting gcj to work with Java source files importing
classes that are on the CLASSPATH.

Case in point:  My CLASSPATH is 
  .:/u/sobolev/agw/java-classes
The directory /u/sobolev/agw/java-classes contains the following file Bar.java:
  public class Bar
  {
    public static void writeln(String s)
    {
      System.out.println(s);
    }
  }
and I have run "javac Bar.java" within that directory to create Bar.class. 

The current directory contains the following file Foo.java:
  import Bar;
  public class Foo 
  {
    public static void main (String[] args) {
      Bar bar = new Bar();
      bar.writeln("Hello, world");
    } 
  }

Note the following:
  % javac Foo.java
  % java Foo
  Hello, world
However:
  % gcj -c Foo.java
  % gcj -o Foo --main=Foo Foo.o
  Foo.o: In function `Foo::main(JArray<java::lang::String *> *)':
  /u/sobolev/agw/tmp/Foo.java:6: undefined reference to `_CL_3Bar'
  /u/sobolev/agw/tmp/Foo.java:6: undefined reference to `Bar::Bar(void)'
  /u/sobolev/agw/tmp/Foo.java:7: undefined reference to
     `Bar::writeln(java::lang::String *)'
  collect2: ld returned 1 exit status

FWIW, I also did
  % gcj -c Bar.java
within /u/sobolev/agw/java-classes, to see whether it would make a difference.
It didn't.

BTW, if I change the first line of Foo.java to be
  import Bar.*;
I once again get
  % javac Foo.java
  % java Foo
  Hello, world
but now
  % gcj -c Foo.java
  Foo.java:1: Can't find default package `Bar'. Check the CLASSPATH
    environment variable and the access to the archives.
  1 error
(This may be a red herring.)

Any idea what I'm missing here?  Thanks.

-- 
Art Werschulz (8-{)}   "Metaphors be with you."  -- bumper sticker
GCS/M (GAT): d? -p+ c++ l u+(-) e--- m* s n+ h f g+ w+ t++ r- y? 
Net: agw@dsm.fordham.edu <a href="http://www.dsm.fordham.edu/~agw/";>WWW</a>
Phone:   Fordham U. (212) 636-6325, Columbia U. (212) 939-7061


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