28

I need to pass a couple of JVM arguments to the JVM which Tomcat is running in so that my application can pick them up.

I want to follow the process outlined in this article to pick up environment variables.

How would I go about doing this?

UPDATE Sorry This is running under windows (7 on my Dev machine 2003 on client server)

0

2 Answers 2

41

Windows:

In your Tomcat /bin folder, you should have a tomcat5w.exe admin app (or in later versions tomcat6w.ex, tomcat8w.exe, etc). Go to the Java tab and add the args in the "Java Options:" box.

enter image description here

Note that when you add new args, you need to add them as NEW LINES in that box (above or below any others there), not as additional arguments IN FRONT or BACK of values on one of the existing lines.

Linux / UNIX:

In *nix, changes to the setenv.sh file should be picked up:

export JAVA_OPTS=-server -Xms2g -Xmx4g -XX:PermSize=64m -XX:MaxPermSize=256m $JAVA_OPTS

Don't touch catalina.sh or other files in bin

5
  • 4
    -1 The Windows service doesn't use the BAT files to start Tomcat. Jun 3, 2011 at 10:16
  • Even when it's running as a windows service? It looks to me that windows executes the C:\apache-tomcat-5.5.28\bin\tomcat5.exe Although there is a command line argument //RS//<SERVICE_NAME> Jun 3, 2011 at 10:16
  • @Aaron, sorry I realised the second I posted the answer.
    – Michael
    Jun 3, 2011 at 10:18
  • 3
    I cannot find this Java tab. I have the service running on Windows 2008R2.
    – Teysz
    Jun 22, 2015 at 11:45
  • I tried using -noverify with the service java options - it doesn't work (the service doesn't start). Any idea?
    – Lin
    May 29, 2017 at 9:03
25

You need to edit the Windows service. There are three ways to do this:

  1. Start Tomcat5w with //MS//ServiceName to get an icon in the system tray which gives you a quick access to the configuration of the service.

  2. Open the service manager in the "Control Panel". There is an entry for Tomcat.

In the editor, there is a tab where you can add additional JVM parameters.

The third way (which I prefer) is to write a script which edits the config for you. This way, you can save the config somewhere for backup. See the docs how to do that (Hint: use tomcat5 //US//...)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.