Posts

Showing posts with the label classloader

order of classloader in java during compile time and run time

order of classloader in java during compile time and run time I've created below class with qualified name java.lang.String in java. java.lang.String package java.lang; public class String { public int getValue() { return 42; } } In Main Class, I have added the below code. public class Main { public static void main(String args) { String s = new String(); System.out.println(s.getValue()); } } The code compile just fine. When I run the code, it fails with below error. Exception in thread "main" java.lang.NoSuchMethodError: java.lang.String.getValue()I at com.Main.main(Main.java:12) I got to understand the java.lang.String is loaded by bootstrap classloader at runtime from rt.jar file. java.lang.String So, I think the order of class loading should be different during compile time and runtime. Can you please give the order of class loading during compile time and runtime. "I've created below c...