Neal
Neal

Reputation: 463

Why does my Java class fail to compile when compiled from inside the package directory?

I have made a directory called "middle" and inside it another directory called "tier" and inside the "tier" directory are OrderManager.java which is an interface and OrderManagerImpl.java having its implementation.

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

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

Why is it so?

Upvotes: 4

Views: 578

Answers (1)

Fabio Vinicius Binder
Fabio Vinicius Binder

Reputation: 13214

Because the compiler expects to find your class inside the proper folder: ./middle/tier . When you try to compile inside the package, the compiler search for your class in ./middle/tier/middle/tier

Upvotes: 8

Related Questions