Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
Q11
Q11
What are tomcat6w.exe/tomcat6.exe (or tomcat7w.exe/tomcat7.exe etc..) ?

Questions on this topic come regularly at various levels. So this is a longish explanation meant basically for real Tomcat/Windows beginners. Apologies in advance for any shortcuts and approximations. You can sort this out by yourself according to your own needs.

Java is a programming language designed to be "compile once, run anywhere". The idea is that when you compile a java program, the java compiler creates a "java bytecode" version of your java program, and this bytecode version can be run by any Java Virtual Machine (a JVM) which runs on any platform (iow under any operating system) where such a JVM has been ported. Microsoft Windows is such a platform, and there exists a JVM which runs on it. Tomcat is a java application, and when it runs on a Windows platform, what really runs as a Windows process is the JVM, which in turn executes the bytecode of the compiled Tomcat application.

Because the JVM has to run on many different platforms, it cannot be too specific for each platform. For example under Windows, the JVM is not very good at running as a Windows Service. Windows Services are supposed to respond in specific ways to "signals" (or "messages") sent by the Windows Services Manager, and the Windows JVM does not really implement the code needed to do that.

To make the JVM really capable to respond to such Windows signals/messages, one solution is to run the JVM inside of a "wrapper" program which is written in such a way that it does respond properly to Windows signals/messages, passes these signals to the JVM in a way which the JVM understands, and returns appropriate messages to the Windows Services Manager to indicate that the JVM started or stopped properly.

The Apache "procrun" software project provides such a wrapper program. Its original documentation can be found here : http://commons.apache.org/daemon/procrun.html. But this documentation is more of the "reference" type : good for someone who already knows what they are looking for, but not very good as an introduction; and it doesn't explain what tomcat7w.exe (or tomcat6w.exe or tomcat5w.exe) and tomcat7.exe (or tomcat6.exe or tomcat5.exe) really are. From there this FAQ entry.

tomcat7.exe is in fact a renamed copy of the "prunsrv" program from the procrun project. This is the "wrapper" mentioned previously. When you install Tomcat as a Windows Service, what you are really installing is the prunsrv program, renamed as tomcat7.exe. This is the program that Windows knows as being the Tomcat Service, and it will send to this program the messages telling the Tomcat Service to start or stop. In turn, tomcat7.exe will run the JVM, and it will translate for the JVM these Windows messages. And the JVM will run Tomcat. Through this subterfuge, Windows will see a Windows Service application named "Apache Tomcat", which runs as a Windows Service and which responds properly to Windows Service messages.

So what is tomcat7w.exe then ? It is a renamed version of the procrun "prunmgr" program. This is in fact a simple graphical Windows Registry editor, which is able to set and modify specific keys and values in the Registry; and these specific keys/values are the ones which are read by tomcat7.exe (the JVM wrapper program mentioned earlier).

When tomcat7.exe launches a JVM, it can pass to this JVM a number of "command-line options" (things such as "-Xmx", "-Dxxx" and so on). To know which command-line options to pass, it reads specific keys/values in the Windows Registry. And these keys/values are the ones which you can set/modify via the tomcat7w.exe program.

One more thing : because the tomcat7.exe wrapper program actually "runs" the JVM, it must match the type of JVM that it runs, in terms of 32bit/64bit version. If you try to start a 64-bit JVM with a 32-bit tomcat7.exe, it won't work, and vice-versa. This is why there are 2 versions of the tomcat7.exe program, a 32-bit version and a 64-bit version. And you must install and use the correct one matching the JVM that you are using. The Tomcat Service installer for Windows normally does that for you automatically; but if you downloade the ZIP version of Tomcat, you may have to select this by yourself.

...

CategoryFAQ