0

Is there a way to stop loading a java library (.jar file) at runtime, if it is on the classpath?

2
  • 1
    What do you want to achieve? Cannot you just remove it from the classpath?
    – Thilo
    Jul 16, 2013 at 5:46
  • 6
    This sounds like a XY Problem. What are you actually trying to achieve? Jul 16, 2013 at 5:46

1 Answer 1

0

Although I agreee with @Joachim Suer that your question sounds like an XY Problem I's try to assume that you want to load some classes dynamically. To do this you probably want to create your own class loader. You do not even have to implement it. You can use URLClassLoader that is a part of your JDK. Its instance can load classes from locations that are not mentioned in static class path of your jvm (using -cp or -classpath command line option).

In this case you have full control on your class loader. You can start and stop using it at any moment.

But again, all written above is just an assumption. Try to explain what your real problem is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.