How to load a class programmatically?
Answer / madhu
public class MainClass {
public static void main(String[] args){
ClassLoader classLoader = MainClass.class.getClassLoader();
try {
Class aClass = classLoader.loadClass("com.tech.MyClass");
System.out.println("aClass.getName() = " + aClass.getName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
| Is This Answer Correct ? | 5 Yes | 0 No |
How do I enable java in google chrome?
Explain issues of old java date api?
What is jpa implementation?
I run a web server. Am I at risk? : java security
Is jdk a compiler?
What is javacpl?
What do you mean by exception handling?
What are jpa annotations?
Can I have multiple main methods in the same class?
What is a container in java?
I get an exception if I remove the static modifier from main?
Where is java installed?