java - hide some class file or package in jar file -


how can export jar without class or package don't want others use,but needed in project,means can't delete them.

this doesn't make lot of sense.

if classes needed compile project, there static dependencies on them in other classes. (otherwise ... able delete / them.)

but if there static dependencies on classes, won't able run applications unless classes present in jar file. if leave classes out of jar stop people using them (or whatever), application die on startup "class not found" exceptions.

if want stop people using classes directly, try following:

  • change classes access "package private". doesn't make impossible use them, makes more difficult.

  • change project dependencies on classes entirely dynamic; e.g. via class.forname(...) or dependency injection. can exclude classes jar required. once again, if application needs use classes, have accessible @ runtime (somehow), , therefore possible (somehow) other people hold of them.

  • change project allow remove classes entirely. sure-fire solution.

finally, before go of trouble should ask why bothering this. why don't let people use classes anyway? stop them getting classes somewhere else ... or implementing own versions scratch?


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -