Set Classpath in Apache Tomcat Permanently
This tutorial will guide you on how to set the classpath in Apache Tomcat permanently, so that we don’t need to set the classpath each time. Apache Tomcat is one the most widely used webservers, but unlike WAMP, XAMPP Apache distributions, Apache Tomcat needs the user to set the classpath after the installation. Once you install Apache Tomcat, to run the server, we need to execute startup.bat present in the bin folder,there is already a file present in bin folder to set the classpath, but it hardly works on most of the machines. Apache Tomcat requires either JAVA_HOME or JAVA_JRE classpath to be set in order to work. Without setting these classpath Tomcat will throw the following error “Either JAVA_HOME or JAVA_JRE is required for Apache to start“.
Set JAVA_HOME Classpath for Apache Tomcat
- Open System Properties (Window Key + Break or Right Click on My Computer -> Properties).
- Select Advanced and then Environmental Variables.
- In System Variables , select Add and enter JAVA_HOME as Variable name and the path of your JDK Folder (not the bin, the outer folder, eg. C:\Program Files\Java\jdk1.6.0_18 ) in Variable value and select OK.
- In System Variables , double click on the value called “PATH” (If PATH doesn’t exist,create one) and in the end of variable value, add “;JAVA_HOME” and select Ok
- (The semicolon is to separate the other entries from JAVA_HOME.
- Click on Ok and Restart your computer.
By following the above methods, you can run Apache Tomcat without setting the classpath each time. There can be many alternate methods to do this, but this one is comparatively easier than others.