I have created a package with the first line "package bookpack;" under which I have created a public class Book with three protected member: title, author and pubDate. The class has been compiled with "javac -d c:\ Book.java". After that compilation, I have verified that under c:\, bookpack directory has been created, and also Book.class file exists. I have tried to create another package "package bookpackB;" under which I have attempted to create a subclass of "Book", writing "extends bookpack.Book". In the subclass I have tried to access the protected member of "Book" class. However, I am unable to compile that subclass.Errors appear that "unable to resolve symbol super, variables of "Book" class etc. However, if I remove all package statements from both the superclass and subclass, all classes are compiled perfectly. I feel problem lies with the package creation. Could some of you please help me in this regard? Thanks in advance!
If I understand correctly you are getting an error while compiling. Is that the case? Is the first package in your classpath when you compile the second class? It might help to show the javac command for the second compile and the specific error message.
Thanks for your reply! As I mentioned, the first package "bookpack"/class " Book" has been copiled. Regarding second package("bookpackB")/class ("ExtBook"), I have used "package bookpackB" and "class Book extends bookpack.book". I have tried to copile it with "javac -d c:\ ExtBook.java". My idea is that the copilation should create directory of "bookpackB" under c:\ and place "ExtBook.class" in that directory. Am I wrong somewhere?
Thanks Richard, it has worked! I have used javac command with classpath switch, as you mentioned. However, I have not used any import statement. What do you think? Do I have to set classpath variable in my batch file? Presently I am using "set classpath C:\j2sdk1.4\LIB ; . ;" Anyway, I appreciate your help.