Hi... I have 2 java programs in which one inherits the other.i used the import statement to inherit the other file in the other..but its givin errors.. i tried creating packages and also tried but all in vain... the object of the first class declared is not accepted in the second one. it gives the following errorS:
the code of 2 programs r given below
plz help me out...... [ edited to break long lines, disable smilies, and to remove the evil tab character -ds ] [ April 12, 2004: Message edited by: Dirk Schreckmann ]
hI sMYLE Put both in the same directory without package and compile.Find Out Whether it works and what is this 'import pool.*' Is connectionPool in it If it is where is the package name in connectionpool
I have found it tricky to get my own packages and imports to work correctly. I strongly suggest you follow the suggestion made by "red bull" and put all your java files in one directory and not worry about import statements. Get it to compile that way before you start organizing your packages. When you get that much to work, make sure each java file has a line such as: package pool; This will define the package that should contain the classes in that file. Also, these files should all be in a subdirectory (or folder) named "pool". Finally, you will need to add the folder that contains this pool folder to your CLASSPATH. If you put your source files in a directory called C:\my_java_files\pool, then you need to add C:\my_java_files to the CLASSPATH variable in order to allow import statements to find the appropriate package and its classes. HTH Layne p.s. Someone, please correct me if I've made any mistakes above. p.p.s. RED BULL: you should change your name to follow the naming policy before a Sheriff arrests you ;-)
smyle khanna, Your code almost compiles. If you remove the import pool.*; statement, then you'll discover that your only remaining problem concerns not handling the thrown exceptions of the ConnectionPool constructor in your subclass constructor. To fix that, you could just add a no argument constructor to your subclass that throws the same exceptions. Now, for help on figuring out the whole "how to get my packages and imports to work thing", let me recommend reading a few past conversations on the subject, which include some step-by-step instructions.