Article updated on

How to find out from which jar a class is being loaded in the server for security manager installed classes

Sometimes we cannot alter the classpath of the J2EE server or Web container and we need to find out if the classpath is loading a class from the right jar.

With this JSP example you only have to upload it to your server and load the URL.

In this example we want to locate from where the is loaded. Change accordingly.

<%@ page import=""%>
//choose the class whose jar you want to locate
Class c =;
URL location = c.getResource('/' + c.getName().replace('.', '/') + ".class");
<title>Get location package</title>
<body bgcolor="#FFFFFF">
<%="Class: "+c.getName()%>
<%="Is located: " + ((c.getProtectionDomain().getCodeSource()==null)?"No source":c.getProtectionDomain().getCodeSource().getLocation()) %>


Upload the JSP and load it with your web browser.

You will see: