Greg's Blog

helping me remember what I figure out

Compiling Java Servlets

| Comments

If you are experiencing a few difficulties compiling your Java Servlets, here are the steps required to configure your environment properly. First of all you will need these 2 development kits:

  • JDK 1.3 [at the time of writing the latest version was 1.3.0_02]
  • JSDK 2.1

OK once you have downloaded these and installed them, copy server.jar and servlet.jar to your <drive letter>:\<JDK install directory>\lib\. Then you will need to add these two files to your classpath. Open up your Control Panel and select System. Once the dialogue is up choose Environment and look for the classpath entry in system variables. Once you have clicked on that variable you should be able to add another entry to the value. Type in the following:

;<drive letter>:\<JDK install directory>\lib\servlet.jar;<drive letter>:\<JDK install directory>\lib\server.jar

Also make sure that your Path has been set ptoperly to relfect your JDK bin directory. In Environment under the variable Path, look for the following entry:

<drive letter>:\<JDK install directory>\bin;<

If it isn’t there then add it. Now if you want to compile one of your Java servlets all you need to type from any location is:

javac JavaProgramName.java

Also note that when typing the above command make sure that you specifying the .java file with it’s proper case. The compiler is case sensitive and hence won’t compile properly, so if you type in: javac javaprogramname.java and the fiel was saved as JavaProgramName.java, then the compiler will throw an error. There you go all done, now you just have to make sure there are no errors in your code.