I have a package structure in Java and it should be accessible as shown below.

How to make Underlying package classes accessible to only Middle package? The TestApp should directly communicate with Interface package only. The TestApp should not get any information about Underlying and Middle package classes. How to do it? Please help
You can put TestApp and Interface in the same package. Then Interface must inherit Middle that use protected methods. Then Middle is in the same Package of Underlying that uses package protected methods.
It does what you want, but honestly, I see no sense of doing that. And it supposes that “Interface Package” is not a Java Interface…
Ceylon Language has probably a better notion of Unit Of Code and Modules, but Java 6,7 & 8 languages are not ready to really hide things to other programmers.