Reputation: 3
This may be a duplicate, but I can't find any solutions that are similar to mine. (I probably just suck at searching)
I'm currently new and this is the first time actually stepping up to ask a dumb question, but I'm currently trying to important packages but it doesn't recognize my packages. I've created a com folder in my C: drive and created two folders named school and home. In the school folder, I have two folders named student and teacher and in the home folder, with multiple classes in each folder. In the home folder, I have a main class that imports the packages from the student and teacher folder, but it won't recognize my packages.
home folder -
hi.java (import com.school.student.; and import com.school.teacher.; )
student folder - multiple class files with (package com.school.student;) at the top
teacher folder - one class file with (package com.school.teacher;) and (import com.school.students.*;)
I can't tell what I'm doing wrong as it's not recognizing com.school.student.; and com.school.teacher.; in the hi.java method.
Upvotes: 0
Views: 82
Reputation: 11
You have to remove period(.) from the end of import statements.
Instead of
com.school.student.;
com.school.teacher.;
use
com.school.student.*;
com.school.teacher.*;
This will import all the classes from com.school.student
and com.school.teacher
packages. It is better to import only those classes which will be used by your class.
You can use any IDE like Eclipse or NetBeans to code. Both of them are free.
Upvotes: 1