Java compilation error: "cannot resolve symbol"

Discussion in 'Java' started by Philipp Gressly, Apr 17, 2005.

  1. exquisitus wrote:
    > I have a simple test package that I am using to learn Java. I have two
    > files, both of which belong to the same package (mypackage). One of the
    > files uses a class defined in the other file. Both files are in the same
    > directory c:\temp\test\mypackage
    >
    > I compiled the non-dependent file without any problem. However, when I
    > tried to compile the file that has a dependency to the other file, I got
    > a "cannot resolve symbol". I don't believe it!. The .class file from
    > the first compilation is right there (where on earth is the compiler
    > looking)?. I tried to spoonfed the compiler by typing the ff (from the
    > c:\temp\test\mypackage directory):
    >
    > javac -c . foo2.java
    >
    > and it still reported the same error !
    >
    > This must be fairly easy to solve. I would appreciate any help. As an
    > aside, could anyone provide me with a simple build.xml file to build
    > this?. The two files are foo1.java and foo2.java. foo2.java has
    > adependency on foo1.java
    >
    > Thanks
    >
    >


    Try the following javac-command with the below mentioned classes
    "Foo1.java" and "Foo2.java" (be aware of the package-declaration, the
    upper- and lowercase Letters in the File- and Classnames and the
    classpath and local directory:



    >cd C:\temp\test
    >javac -classpath . mypackage/*



    File Foo1.java:
    >>>

    package mypackage;

    public class Foo1 {
    Foo2 foo2;
    }
    <<<

    File Foo2.java
    >>>

    package mypackage;

    public class Foo2 {
    }
    <<<

    Hope that hepls
     
    Philipp Gressly, Apr 17, 2005
    #1
    1. Advertising

  2. Philipp Gressly

    exquisitus Guest

    I have a simple test package that I am using to learn Java. I have two
    files, both of which belong to the same package (mypackage). One of the
    files uses a class defined in the other file. Both files are in the same
    directory c:\temp\test\mypackage

    I compiled the non-dependent file without any problem. However, when I
    tried to compile the file that has a dependency to the other file, I got
    a "cannot resolve symbol". I don't believe it!. The .class file from
    the first compilation is right there (where on earth is the compiler
    looking)?. I tried to spoonfed the compiler by typing the ff (from the
    c:\temp\test\mypackage directory):

    javac -c . foo2.java

    and it still reported the same error !

    This must be fairly easy to solve. I would appreciate any help. As an
    aside, could anyone provide me with a simple build.xml file to build
    this?. The two files are foo1.java and foo2.java. foo2.java has
    adependency on foo1.java

    Thanks
     
    exquisitus, Apr 17, 2005
    #2
    1. Advertising

  3. Philipp Gressly

    exquisitus Guest

    Philipp Gressly wrote:
    > exquisitus wrote:
    >
    >> I have a simple test package that I am using to learn Java. I have two
    >> files, both of which belong to the same package (mypackage). One of
    >> the files uses a class defined in the other file. Both files are in
    >> the same directory c:\temp\test\mypackage
    >>
    >> I compiled the non-dependent file without any problem. However, when I
    >> tried to compile the file that has a dependency to the other file, I
    >> got a "cannot resolve symbol". I don't believe it!. The .class file
    >> from the first compilation is right there (where on earth is the
    >> compiler looking)?. I tried to spoonfed the compiler by typing the ff
    >> (from the c:\temp\test\mypackage directory):
    >>
    >> javac -c . foo2.java
    >>
    >> and it still reported the same error !
    >>
    >> This must be fairly easy to solve. I would appreciate any help. As an
    >> aside, could anyone provide me with a simple build.xml file to build
    >> this?. The two files are foo1.java and foo2.java. foo2.java has
    >> adependency on foo1.java
    >>
    >> Thanks
    >>
    >>

    >
    > Try the following javac-command with the below mentioned classes
    > "Foo1.java" and "Foo2.java" (be aware of the package-declaration, the
    > upper- and lowercase Letters in the File- and Classnames and the
    > classpath and local directory:
    >
    >
    >
    > >cd C:\temp\test
    > >javac -classpath . mypackage/*

    >
    >
    > File Foo1.java:
    > >>>

    > package mypackage;
    >
    > public class Foo1 {
    > Foo2 foo2;
    > }
    > <<<
    >
    > File Foo2.java
    > >>>

    > package mypackage;
    >
    > public class Foo2 {
    > }
    > <<<
    >
    > Hope that hepls



    Thank you very, very much - It worked !!!
     
    exquisitus, Apr 18, 2005
    #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. vivienne wykes
    Replies:
    4
    Views:
    923
    Roedy Green
    Jul 28, 2004
  2. jrh001
    Replies:
    0
    Views:
    380
    jrh001
    Nov 25, 2004
  3. Darren
    Replies:
    10
    Views:
    1,465
    Darren
    Nov 15, 2005
  4. adi
    Replies:
    4
    Views:
    535
    Roedy Green
    Feb 8, 2006
  5. Roy Gourgi
    Replies:
    1
    Views:
    694
    Oliver Wong
    Sep 27, 2006
Loading...

Share This Page