I have a Main.java file:

public class Main{

  private EntityDrawer entityDrawer;

  public void setEntityDrawer(EntityDrawer entityDrawer) {
    this.entityDrawer = entityDrawer;
  }

  public EntityDrawer getEntityDrawer() {
    return entityDrawer;
  }
}

class EntityDrawer {

  private Empleado empleado;  

  public Empleado getEmpleado() {
    return empleado;
  }

  public void setEmpleado(Empleado empleado) {
    this.empleado = empleado;
  }

}

If I try to access from another file, it works if I only try to access the entityManager:

Main main = new Main();
main.getEntityDrawer(); // NO PROBLEM!

But if I try to access one of the attributes (even if public) from entityManager, it does not work:

Main main = new Main();
main.getEntityDrawer().getEmpleado(); // Gives error "The type EntityDrawer is not visible"

I cannot understand why is happening, could someone give me some insight into this issue?...

3

There are 3 answers

2
Peter Lawrey On BEST ANSWER

I assume you are trying to use a package local class EntityDrawer in another package, which you cannot do.

Try making the class public

0
kdabir On

Make the class public or move the calling class to same package.

0
Mohasin Ali On

I too got annoyed with this problem, I removed unnecessary jar files and add only required jar files in the classpath. Sometimes if you put redundant jar files in the class path will leads to conflicting of the jar files and that will shows the error(like "the type org.apache.lucene.index.DirectoryReader is not visible").

Thank you.