How to change the temporary directory in jetty9?

2019-09-19 06:23发布

问题:

I want to make a temp directory for my jetty and change the default /tmp directory to mine temp directory, I tried this

java -Djava.io.tmpdir=/home/jetty/temp

When I want to start my jetty and it worked, but I'm looking for a way to change the temp directory once and for all. Is there any configuration or xml or something that I can change?

回答1:

Are you wanting to change the working directory for your webapp? or the overall temp directory for all processes that might be running under Jetty?

For the webapp specific case, see the prior answer about changing the temp directory for webapps.

For all processes in jetty, add the following 2 lines to your ${jetty.base}/start.ini

--exec
-Djava.io.tmpdir=/home/jetty/temp

Note: this will cause jetty-dist/start.jar to fork a new process for Jetty server.



标签: java Jetty