#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    15
    Rep Power
    0

    Extending a class


    Hi All,

    I am having a problem extending a class and I am not sure why.

    When I run:
    C:\tomcat5\jakarta-tomcat-5\dist\webapps\FaustJSP\WEB-INF\classes\booklibrary>javac ChildrenBook.java

    When I try to compile the .java file I get the following error:

    ChildrenBook.java:3: cannot resolve symbol
    symbol : class Book
    location: class ChildrenBook
    public class ChildrenBook extends Book
    ^
    1 error

    Here is my ChildrenBook.java file:
    package booklibrary;

    public class ChildrenBook extends Book
    {
    private int minimumAge;

    public int getMinimumAge()
    {
    return this.minimumAge;
    }
    public void setMinimumAge(int a)
    {
    this.minimumAge = a;
    }
    public ChildrenBook(String title)
    {
    super(title);
    }
    }

    I have the Book.java and Book.class files within the same directory as the ChildrenBook.java file above.

    Here is the code for Book.java
    package booklibrary;

    public class Book
    {
    private String title;
    public String getTitle()
    {
    return title;
    }
    public void setTitle(String newTitle)
    {
    this.title = newTitle;
    }
    public Book(String title)
    {
    this.title = title;
    }
    }
    Book.java compiles correctly.

    Thanks,
    CC
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Bogotá, Colombia
    Posts
    43
    Rep Power
    12
    The classpath has to contain the path Book.class is in, cause it's not finding it.

    Try this:
    set CLASSPATH=%CLASSPATH%;C:\tomcat5\jakarta-tomcat-5\dist\webapps\FaustJSP\WEB-INF\classes\booklibrary
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    15
    Rep Power
    0

    Classpath already set


    The classpath is already set to go all the way down to the booklibrary directory.
    --
    cc
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Bogotá, Colombia
    Posts
    43
    Rep Power
    12
    If you're in the booklibrary dir running javac ChildrenBook.java you'll get an error as it'll look for Book.java in a dir named booklibrary inside the current dir. You have to cd .. and then run javac booklibrary/ChildrenBook.java

    Does that work?

IMN logo majestic logo threadwatch logo seochat tools logo