Why can't my Java class compile when compiling from the package directory?

I created a directory called "middle", and inside it another directory called "level", and inside the "level" - OrderManager.java, which is the interface and OrderManagerImpl.java that has its implementation.

The problem is when I try to compile OrderManagerImpl.java from outside the middle.tier package that it compiles, but when I do the same inside the package, it causes the following error:

  OrderManagerImpl.java:6: cannot find symbol
 symbol: class OrderManager
 public class OrderManagerImpl extends java.rmi.server.UnicastRemoteObject implements OrderManager {

Why is that?

+4
source share
1 answer

Because the compiler expects to find your class inside the corresponding folder: ./ middle / tier. When you try to compile inside a package, the compiler searches for your class in. / Middle / tier / middle / tier

+8
source

All Articles