Hi, In my code I am using function escapeHtml() belonging to class org.apache.commong.lang.StringEScapeUtils. I want the JVM to output in verbose mode , that StringUtils class is being loaded from org-apache-commons.jar alongwith the path of the jar file.
Further , I tried out the java -verbose option, but required info is printed only for the classes belonging to the J2SE package. When it comes it to external classes supplied by jar files, no such info is printed .
You can use ClassLoaders to find files, as well as loading Classes. The trick here is that if you turn a fully-qualified Class into it's file representation, you can use the ClassLoader to get the URL location for this 'file', which includes the name of the JAR containing the Class it loaded. I won't give you all the code, it isn't that hard and I don't want to spoil the fun:
1) Turn the class name into a file name eg java.lang.String into java/lang/String/class 2) GET the file as a RESOURCE afetr you GET the ClassLoader 3) Print the URL. 4) Parse the URL for the actual data you want.
Received via PM: (Please keep conversations on the site, we don't always check emails and most people will ignore code requests via PM, we just don't have time. Also, if we keep it here others can help and it will help other people too)
But there are two issues:
*Can the solution be implemented without changing the original code? *Can you provide some hints how to implement it ?
I won't have chance to look at this for a while. Maybe someone else can help.