Use an URLClassLoader
for this. The code might be something along the lines of:
File f = new File("C:/dir");
URL[] cp = {f.toURI().toURL()};
URLClassLoader urlcl = new URLClassLoader(cp);
Class clazz = urlcl.loadClass("distantinterfaces.DistantClass");
More Related Contents:
- How do I resolve ClassNotFoundException?
- What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?
- Find where java class is loaded from
- Java, Classpath, Classloading => Multiple Versions of the same jar/project
- java.lang.ClassNotFoundException in spite of using CLASSPATH environment variable
- Determine which JAR file a class is from
- How to get names of classes inside a jar file?
- Java – how to load different versions of the same class?
- How to use ClassLoader.getResources() correctly? [duplicate]
- Check if class exists in Java classpath without running its static initializer?
- ClassLoader getResourceAsStream returns null
- Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
- URLClassLoader and accessibility of package-private methods
- How to instantiate an Embeddable class?
- How do I correctly implement this code segment without getting a logic error? [closed]
- How do you find all subclasses of a given class in Java?
- Can we instantiate an abstract class?
- Why can outer Java classes access inner class private members?
- What is the difference between Integer and int in Java?
- Static nested class in Java, why?
- Curly braces in “new” expression? (e.g. “new MyClass() { … }”)
- oracle.jdbc.driver.OracleDriver ClassNotFoundException
- how to make jni.h be found?
- Can we instantiate an abstract class directly? [duplicate]
- Android Call a method from another class
- I am getting “java.lang.ClassNotFoundException: com.google.gson.Gson” error even though it is defined in my classpath
- How to replace classes in a running application in java ?
- Java: Use import or explicit package / class name?
- How can I read file from classes directory in my WAR?
- Eclipse classpath entries only used for tests