(newbie) compiling problem

Discussion in 'Java' started by Gary, Aug 30, 2003.

  1. Gary

    Gary Guest

    OK, I decided to try RMI, but I'm getting stuck on compiling. I've
    relied so long on Forrte and Eclipse that I can't remember how to
    compile.

    I have two classes: Foo, and Bar. Bar extends Foo. The point is that I
    have one class that needs the other to compile.

    I've tried Textpad and the command line, and neither works, although I
    have no problem when I do it from Eclipse.

    I've put the in the dedfault package and trry this:
    javac Foo.java
    javac Bar.java

    Foo compiles OK, but when I go to compile Bar, I get this message:
    ---------------------------------
    C:\eclipse\workspace\MyTest\Bar.java:2: cannot resolve symbol
    symbol : class Foo
    location: class Bar
    public class Bar extends Foo {}
    ^
    1 error

    Tool completed with exit code 1
    ---------------------------------

    I've also triedd putting them in a package together. Nothing works.
    I'm sure this is something simple. I know I've done this a million
    times, but I can't remember what I did different.

    Thanks for the help, and let this be a warning to any of you who think
    an IDE is going to solve all your problems.
     
    Gary, Aug 30, 2003
    #1
    1. Advertising

  2. Gary

    D Goldman Guest

    > you propably don't have foo.class in your classpath.
    >
    > do something like that in your console:
    >
    > javac -classpath Path/To/Foo Bar.java



    If both Foo and Bar are in the same directory, then you can just do the following:
    javac -classpath . Bar.java

    Make sure you incluse the ".", since it points to the current directory.


    <a href="http://d-goldman.org">Posted by: </a>
    <a href="http://www.geocities.com/danielgoldman2/index.html>Daniel Goldman</a>
     
    D Goldman, Aug 31, 2003
    #2
    1. Advertising

  3. On 30 Aug 2003 08:56:50 -0700, (Gary) wrote:

    >OK, I decided to try RMI, but I'm getting stuck on compiling. I've
    >relied so long on Forrte and Eclipse that I can't remember how to
    >compile.
    >
    >I have two classes: Foo, and Bar. Bar extends Foo. The point is that I
    >have one class that needs the other to compile.
    >
    >I've tried Textpad and the command line, and neither works, although I
    >have no problem when I do it from Eclipse.
    >
    >I've put the in the dedfault package and trry this:
    >javac Foo.java
    >javac Bar.java
    >
    >Foo compiles OK, but when I go to compile Bar, I get this message:
    >---------------------------------
    >C:\eclipse\workspace\MyTest\Bar.java:2: cannot resolve symbol
    >symbol : class Foo
    >location: class Bar
    >public class Bar extends Foo {}
    > ^
    >1 error
    >
    >Tool completed with exit code 1
    >---------------------------------
    >
    >I've also triedd putting them in a package together. Nothing works.
    >I'm sure this is something simple. I know I've done this a million
    >times, but I can't remember what I did different.
    >
    >Thanks for the help, and let this be a warning to any of you who think
    >an IDE is going to solve all your problems.



    Assuming the following source:

    File Foo.java:
    package a;

    class Foo
    {...}
    -----
    File Bar.java:
    package a;

    class Bar extends Foo
    {...}
    -----
    Afterwards Bar.java and Foo.java have to be in a subdir named a.
    Preferably you should run javac as

    javac -da a/Bar

    now from the dir below a. This would compile both files (it does it
    for me).

    Other option: remove the package statements and start the javac from
    the same dir the *.java file are in.
     
    Thomas Thrien, Sep 1, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jk
    Replies:
    1
    Views:
    528
    Mike Treseler
    Jan 4, 2004
  2. Libin Xie

    newbie question with compiling

    Libin Xie, Oct 24, 2003, in forum: Java
    Replies:
    5
    Views:
    564
    Libin Xie
    Oct 26, 2003
  3. Garrett Cooper
    Replies:
    0
    Views:
    561
    Garrett Cooper
    Feb 24, 2009
  4. Garrett Cooper
    Replies:
    0
    Views:
    502
    Garrett Cooper
    Feb 24, 2009
  5. Lon Baker
    Replies:
    1
    Views:
    226
    Csaba Henk
    Mar 21, 2005
Loading...

Share This Page