Compiler Error J0169

Cannot access 'identifier' -- only public classes and interfaces in other packages can be accessed

The compiler detected an attempt to access a non-public class or interface contained within another package. Only classes or interfaces defined with the modifier public can be accessed in other packages. Check the access level of the class or interface you are accessing in the other package to ensure that it is public and compile again.

The following example illustrates this error:

//Source located in 'Boxes.Java' in the 'Box' package
package Box;
public class Box{
   TapeRoll tr = new TapeRoll();
   //Do meaningful stuff here
}
class TapeRoll{
   //Define the class here
}

//Source located in 'Simple.java'
import Box.TapeRoll;
public class Simple{
   public static void main(String args[]){
      Box.TapeRoll tr = new Box.TapeRoll();
      //error: cannot access a 'non-public' class in a different package
   }
}