Tuesday, October 16, 2007

Which class or resource is being lodaed?

I was having a problem with spring not being able to parse the applicationContext.xml. I finally checked and found out the wrong applicationContext.xml was first in the CLASSPATH. The code to do this is easy: System.out.println(this.getClass().getClassLoader().getResource("applicationContext.xml")); You can also find class files. To find java.lang.Object use System.out.println(this.getClass().getClassLoader().getResource("java/lang/Object.class")); The result is something like: jar:file:/C:/Program%20Files/Java/j2sdk1.4.2_14/jre/lib/rt.jar!/java/lang/Object.class Notice how the JRE version is in the output.

No comments: