Class loading

I was experimenting something wiht class loading so found this scenario.

I have created an interface and implementation and made a jar file and kept it in java ext directory, so its loaded by extension class loader and everything works fine.

Now i created another interface in my java application with same class name but different method names. When i use this interface in any of my other classes it gives compilation error when i try to access the method of interface placed in ext directory.

But at runtime it tries to invoke method only existing in interface of ext directory

Why is this anamoly?

[633 byte] By [chidu123a] at [2007-10-3 1:38:10]
# 1

You can analyse the behaviour youself by enabling the verbose in javac & java command. This will display class loading sequence.

e.g. javac -verbose MyClass.java

java -verbose MyClass.java

While compiling you are getting error since classloader is loading the class in your application directory before ext directory.

While running class, classloader is loading the class in your ext directory before application directory.

Let me know in case of any queries.

j_pravina at 2007-7-14 18:36:22 > top of Java-index,Desktop,Runtime Environment...