Tomcat installation on 64-bit Windows
Developer and engineer skills seem to overlap lass and less as technologies progress. That leaves developers dependant upon system administrators to provide the platforms for development, and system administrators dependant upon developers for scripting complex workflows and applications. The goal is to do this as inexpensively as possible.
Apache and Tomcat are respected technologies that run the majority of servers on the internet today. In fact, many browser based-products installed on local machines utilize Tomcat on the back-end. For example, the HP suite of QA and testing tools all utilize Tomcat for their scripting engine. You could use a commercial product such as WebSphere, but at the current price of over $13,000 for a single processor, why would you?
Tomcat can be a bit tricky to install on Windows Server 2008 R2. This is because it is a 32-bit application that you are trying to run as a service on a 64-bit operating system. It will work, but you need some special tweaking in order to make it happy. Whenever possible, it is best to install Tomcat on Linux. This also saves on licensing costs. But as the purpose of this document is to explain how to do it on 64-bit Windows, let's see how to do it.
- Windows Server 2008 R2 VM on Hyper-V
- 2GB of RAM
- 40GB HDD
- LAN connection to virtual network
Third party requirements
- Oracle JDK 7 or later
- Tomcat 7.0 pr later
Steps to install Java and Tomcat
- In the Microsoft Server Manager on the Hyper-V server, expand the roles to get to the Hyper-V management app.
- Create a new virtual machine according to the system configuration above.
- Once the configuration is complete, activate the server. Failure to complete this step will cause the service to fail within three days.
- Perform all of the updates through Windows Update for Recommended and Optional. It is not necessary to install the additional language files.
- Turn off UAC in Windows. A reboot will be required.
- Go to oracle.com and download the latest JDK. As of this writing, the most current version is jdk-7u11-windows-x64.exe. You will need to accept the license agreement in order to download. Total file size is 90.41MB.
- Install the JDK with all options. This will install the required JRE as well. Write down the install location. You will need this when configuring environment variables later.
- Go to http://tomcat.apache.org and download the latest Tomcat server. You will need the 32-bit/64-bit Windows Service Installer for Tomcat to install properly as a service.
- Install Tomcat accepting the default options. You can select the Host Manager and Examples, but this is not necessary.
- Note the default ports that are used for Tomcat. Since these are standard ports, it is best not to change them. Since we are not installing the Host Manager component, we do not need to set a user and password here.
- Make sure to point to the JRE path you wrote down in step 7 above.
- Make a note of the instlalation folder as you will need this later.
- Open system properties. Go to environment variables. In system variables add new:
- Variable name "JRE_HOME", value "C:\Program Files\Java\jre7" . This is the path location from step 7.
- Variable name "JAVA_HOME", value "C:\Program Files\Java\jdk1.7.0_11" . This subfolder name will change based on the version installed.
- Variable name "CATALINA_HOME", value "C:\Program Files\Apache Software Foundation\Tomcat 7.0" . This is the value we wrote down in step 12 above.
- Variable name “CLASSPATH”, value “%CATALINA_HOME%\lib\servlet-api.jar”
IMPORTANT: If you ever update Java, these variables need to be re-verified.
- Edit the PATH variable to append the new paths: a. Variable name "PATH", value "%SystemRoot%\system32; ... ;%JAVA_HOME%\bin;%JRE_HOME%\bin;%CATALINA_HOME%\BIN" .
- Click on the service quick launch icon for Tomcat in the system tray. You will see the startup type is Manual. Set this to Automatic and make sure the service is started.
- In a browser, go to http://localhost:8080/ . You should see the default Tomcat site.
The installation of Java and Tomcat is now complete.
Compile Java code
You should now be able to begin the process of compiling Java code on the server and installing it. Software development is not within the scope of this document. Once your file is created and saved, go to a command prompt and enter the following command.
javac –g filename.java
This will compile the Java application into the appropriate classes so that they can be used in Tomcat. Pay attention to the output to determine if there are any errors in compiling. If there are, it is most likely either an error in the file name or an error in the CLASSPATH environment variable.
Install the code
There are several things that must be done in order to deploy the application to the server. These include building the web.xml file, index.html file and configuring the firewall to allow only the IP range of Halogen servers access to TCP port 8080 on the Tomcat server. Those will be covered in later lessons.