Hi I'm new to programming so I need a little help with packages. I have created 2 packages test1 and test2 with p1.java and p2.java respectively. Both have default access.
I'm trying to extend p1 with p2 and have tried to import test1 but the error im getting is that I there is no package called test2 and there is no class called p1. I have also changed the access to public but it is not helpin.
Thnaks in Advance
newcoder310 0
Junior Poster in Training
Recommended Answers
Jump to PostYou can extend a class from a package but you can't extend the package itself
and you will have to show your directory structure and how you do your import statements
Jump to PostAre the both packages in the same sourse package?
They just can't
That is precisely why packages were invented
Jump to PostUnder which directory did you put the .java files as well as the .class files. I mean that for example you should do something like this:
Folder : src/test1
File: p1.javaFolder : src/test2
File: p2.java-----------
Folder : folder path/comp/test1
File: p1.classFolder : folder …
Jump to PostWhere did the p1.class file as created? Did you set the classpath for that package?
All 14 Replies
pbl 22
Junior Poster
lcy320stud 0
Newbie Poster
pbl 22
Junior Poster
newcoder310 0
Junior Poster in Training
Shanki87 0
Newbie Poster
newcoder310 0
Junior Poster in Training
javaAddict 900
Nearly a Senior Poster Team Colleague Featured Poster
newcoder310 0
Junior Poster in Training
Shanki87 0
Newbie Poster
javaAddict 900
Nearly a Senior Poster Team Colleague Featured Poster
newcoder310 0
Junior Poster in Training
javaAddict 900
Nearly a Senior Poster Team Colleague Featured Poster
newcoder310 0
Junior Poster in Training
JKP() 0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.