Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify location of tomcat temporary folder?

Tags:

tomcat7

When I start embedded tomcat, it creates a folder name "tomcat." + myportnumber for example: tomcat.8080. How can I specify the location of this temp folder. I am using maven, so I want this folder to be in the target folder so it will get clean with mvn clean command.

I am using embedded tomcat version 7.0.26

like image 908
Sean Nguyen Avatar asked Oct 13 '12 17:10

Sean Nguyen


1 Answers

Use public void setBaseDir(String basedir) method.

"Tomcat needs a directory for temp files. This should be the first method called. By default, if this method is not called, we use: - system properties - catalina.base, catalina.home - $HOME/tomcat.$PORT ..."

import org.apache.catalina.startup.Tomcat;

Tomcat tomcat = new Tomcat();
tomcat.setBaseDir("/mytmpfolder");
tomcat.addWebapp("/mywebapp", "/path/to/mywebapp");
tomcat.start();
tomcat.getServer().await(); 
like image 160
acheron55 Avatar answered Oct 18 '22 07:10

acheron55