MattWeiler
MattWeiler

Reputation: 790

Java Portable Tomcat creating directories on desktop

I've recently had to take over a project from an old co-worker; this project is written in JAVA, uses Java Web-Start and uses a light Java library (org.apache.catalina.startup.Tomcat).

Whenever the Tomcat server starts-up and I first interact with the web apps, it creates 3 directories (store, sys, temp) on the Windows desktop.

When I look at a normal Tomcat installation, those directories exist in the tomcatHome\bin\ directory.

Question

Does anyone know how to redirect the creation of these directories to my C:\TomcatHome\ directory?

Below is a snippet of my code:

import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.loader.WebappLoader;

...

// Define the user.dir directory.
System.setProperty( "user.dir", "C:\\TomcatHome" );
// Print out the user.dir and user.home system variables.
System.out.println( "user.dir = " + System.getProperty( "user.dir" ) );
System.out.println( "user.home = " + System.getProperty( "user.home" ) );

...

Tomcat m_tomcat = new Tomcat();
m_tomcat.setBaseDir( "C:\\TomcatHome" );
m_tomcat.setPort( 5009 );
m_tomcat.getHost().setDeployOnStartup( true );
m_tomcat.getHost().setAutoDeploy( true );
m_tomcat.getHost().setAppBase( "C:\\TomcatHome\\webapps" );
m_tomcat.getServer().setPort( 5109 );
m_tomcat.getServer().setShutdown( "SHUTDOWN" );

...

// Add abc web-application to Tomcat.
Context ctx = m_tomcat.addWebapp( null, "/abc", "abc" );
ctx.setLoader( new WebappLoader( class.getClassLoader() ) );
// Add xyz web-application to Tomcat.
ctx = m_tomcat.addWebapp(null, "/xyz", xyz );
ctx.setLoader( new WebappLoader( class.getClassLoader() ) );
// Add ROOT folder to Tomcat.
ctx = m_tomcat.addWebapp(null, "", "ROOT" );
ctx.setLoader( new WebappLoader( class.getClassLoader() ) );

...

m_tomcat.start();

This code prints-out:

user.dir = C:\TomcatHome
user.home = C:\Users\myName

Upvotes: 0

Views: 333

Answers (1)

fcm
fcm

Reputation: 6463

These are temporary directories. As seen here check catalina.sh for the temp folder configuration.

Upvotes: 2

Related Questions