access modifiers - How can classes be made to be accessible from different package but not accessible from different library/ jar in java? -


I want my library / jar in Java so that only its behavior (exposed interface) can be made public and the other - I want to use different packages to be able to moderate the public code for the outside world.

How can I make classes accessible to each other from different packages within a single jar, but can not reach any customer outside the jar?

You can not do this easily in normal Java, though OSGI makes it possible. Generally, to create a separate API library with the interface and its "private" classes are a better way to implement those interfaces. Then the client code can use the interface to interact with your library, but there is no need to know about the details.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -