≡ Menu

How to find out which jar files are loaded by your Application?

  •  
  •  
  •  

At times you may want to find out which jar files are loaded by your Application. It is especially useful if you are dealing with classes present in multiple jar files and causing ClassCast exceptions. It is also useful if you are receiving ClassNotFound error and want to ensure the jar file that has the class file is loaded by your application.

There are few ways to do this.

  1. Use –verbose:class flag with your java command line.

    This option enables loading and unloading of classes. It shows the jar file from which the class is loaded. Be aware that the logs can get very excessive.

  2. If your Application Server supports, there is probably a class loader viewer. Give it a shot

    WebSphere:

    Login to Admin console and navigate to Troubleshooting -> Class     Loader Viewer

    WebLogic:

    Oracle provides a ClassLoader Analysis tool. You can access the tool using the following URL

    http://wls-host:port/wls-cat

  3. There is a cowboy way of finding out all files loaded by a process from OS level.

    Windows:

    Use the Windows SysInternals tool ProcessExplorer. It is a terrific tool to get process level insights.

    Tip: Once you open the tool click on View -> Lowner Pane View -> Handles.

    https://technet.microsoft.com/en-us/sysinternals/processexplorer

    Linux:

    Use the almighty ‘lsof’ command (List of Open Files). There is nothing that lsof command cannot show.

    lsof –p <pid>

Happy Monitoring !!


  •  
  •  
  •  

Comments on this entry are closed.