Home » Java » Java – Import class from another package in a different directory-Exceptionshub

Java – Import class from another package in a different directory-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have arranged my project as follows:

myProject  
¦  
¦---Directories  
¦   ¦  
¦   ¦--ArrayDirectory.java  
¦   ¦--ArrayListDirectory.java  
¦   ¦--HashMapDirectory.java  
¦   ¦--Directory.java  
¦  
¦---Other  
    ¦  
    ¦--Entry.java  
    ¦--Inputter.java  

All the classes in the Directories file have package directories; at the top, and those in Other have package other;

Currently, in all the classes in Directory, I am trying to use the class Entry using import other.Entry; but this is giving the compilation error “package other does not exist”.

I’m not sure where I’ve gone wrong: package names?, file structure?, import statements?

How to&Answers: