Q : Is there a function in Java to retrieve the Tomcat (Catalina) home directory?
A : Yes, Tomcat home directory or Catalina directory is stored at the Java System Property environment. If the Java web application is deployed into Tomcat web server, we can get the Tomcat directory with the following command
System.getProperty("catalina.base");
Reference: How to find the path of webapps directory using java