Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javabean subclass does not compile. 1

Status
Not open for further replies.

cyan01

Programmer
Mar 13, 2002
143
US
Hi, Experts,

I'm new to jsp and javabean. I have a very simple base class Book.java and a subclass TechnicalBook.java. The file structure is as follows:

%CATALINA_HOME%\webapps\test\WEB-INF\classes\booklibrary\Book.java
%CATALINA_HOME%\webapps\test\WEB-INF\classes\booklibrary\TechnicalBook.java

Here is the code of Book.java:

Code:
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;
  }
}

And here is the subclass:

Code:
package booklibrary;

public class TechnicalBook extends Book
{
  private String skillLevel;
  public String getSkillLevel()
  {
    return this.skillLevel;
  }
  public void setSkillLevel(String s)
  {
    this.skillLevel = s;
  }
  public String toString()
  {
    return getTitle();
  }
  public TechnicalBook(String title)
  {
    super(title);
  }
}

The base class was compiled ok. But the subclass does not complie:

Code:
%CATALINA_HOME%\webapps\test\WEB-INF\classes>javac booklibrary\TechnicalBook.java

booklibrary\TechnicalBook.java:3: cannot find symbol
symbol: class Book
public class TechnicalBook extends Book
                                   ^
booklibrary\TechnicalBook.java:20: cannot find symbol
symbol  : method getTitle()
location: class booklibrary.TechnicalBook
    return getTitle();
           ^
2 errors

BTW, I am using jdk 1.5 on win xp. Thank you very much for your help.
 
cd %CATALINA_HOME%\webapps\test\WEB-INF\classes
set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\webapps\test\WEB-INF\classes
javac booklibrary\*.java

Ta Da !

Its happening because you need to set your CLASSPATH so the compiler knows where Book.class is.

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top