How to get the Tomcat home directory in Java

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");
Tags :

About the Author

mkyong
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

  • Anbazhagan

    Hi

    I am using this line System.getProperty(“catalina.base”); in coding but i through null value. Is any way to get the tomcat path thruough java?

    • Anbazhagan

      I am using this line System.getProperty(“catalina.base”); in coding but it through null value. Is any way to get the tomcat path thruough java? I am using linux. I have installed tomcat in root.

  • http://anjanb.wordpress.com anjan bacchu

    hi there,

    thanks for this info. I needed this for my work.

    BR,
    ~A