|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Classpath already set
The classpath is already set to go all the way down to the booklibrary directory.
-- cc |
|
#4
|
|||
|
|||
|
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? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Extending a class |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|