Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 442
Neal Avatar asked Feb 28 '23 17:02

Neal


1 Answers

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

like image 115
Fabio Vinicius Binder Avatar answered Mar 05 '23 16:03

Fabio Vinicius Binder