WebSite
Server-Side Java(tm) SDK
Getting Started
Powered by Java

Robert B. Denny - Version 0.3 (experimental)
Back to overview

Test WebSite Java Support

WebSite Professional includes a server-side Java runtime package which allows you to run Java applications via CGI. The components of this are in the WebSite\java\ directory. It uses the WebSite\java\classes directory as the root for its class searching. The Java base class package is also included, located in WebSite\java\lib\classes.zip (do not unzip this!). In short, WebSite Professional is server-side Java ready.

Be sure you are reading this document through your server (the URL you see must start with http://). Here is a sample application (a Java version of the venerable Pizza sample), so you can test the server-side Java package now. Try it!

Here is a listing of the source code for the sample. Have a look!.

The Two Common Traps

There are two things that trip people up most often when getting started with Java:

Getting Set Up

To get started developing your own server-side Java programs with WebSite Pro, complete the following steps:

  1. Consider purchasing Symantec Cafe. If you do, you can skip steps 2 and 3 in this section. Cafe comes with an enhanced JDK and its setup takes care of the CLASSPATH.

  2. Download the Java Developer's Kit 1.0.1 for Win32 (the JDK) from Sun and install it. It is free for personal use. Be sure your PATH variable contains the bin\ directory of the JDK.

  3. Set up your CLASSPATH environment variable. The JDK documentation is unclear on this. In the release JDK 1.0.1, the Java API classes are contained in a ZIP file (uncompressed) in the JDK lib\ subdirectory. You do not need to unpack this archive. Simply include the full pathname of the archive in your CLASSPATH. The class loader will load right out of the ZIP file. If you installed the JDK into C:\java\, your CLASSPATH should be (at a minimum):

    .;C:\java\lib\classes.zip

    Note the . at the beginning, which allows you to compile and test from the current directory (anywhere you want). Also note that the usage display on the Java runner java.exe says that the CLASSPATH should be colon-separated. This is wrong. On Win32, use the usual semicolon-separated path syntax and native pathname (backslash delimiters).

  4. Adjust the runtime CLASSPATH used by WebSite Pro to reflect any additions or changes you made to the class locations, The runtime CLASSPATH is independent and controlled by a Registry value:

    HKEY_LOCAL_MACHINE\Software\Denny\WebServer\CurrentVersion\CGI\

    Java ClassPath:REG_SZ:
    runtime class path

  5. Map the entire JDK tree into your web using WebSite Pro's document mapping. Create a mapping for the URL /java/ to the root of the JDK tree (for example C:\java\). This is essential for the SDK API documentation to work correctly! It assumes that the JDK API docs are accessible via URL path /java/doc/api/.

    Also, with this mapping you can fetch the classes and HTML documents that accompany the sample applets. Playing with the applet samples is a good way to become familiar with the JDK and with Java itself. Don't worry too much about being an expert applet programmer right away, just dive in and play. Don't do your development work in a directory within the JDK, or all of your work will be web-visible!

The WebSite Professional installation creates an association that couples .clx with the full physical pathname of the javaw.exe program (part of this SDK). The .clx extension stands for class proxy. See the section Java and Windows CGI for information on how these proxy files relate to the actual .class files (Java executables).

Author's Suggestions

In addition to the above required steps, there are several things you should consider doing to make your Java programming experience more pleasurable and productive. These will take some time, but believe me the time is a great investment!

Symantec's Java Tools

This is not an endorsement or recommendation.

Symantec Cafe

Symantec has recently released Symantec Cafe for Windows 95 and NT, an integrated development environment for Java. My personal opinion is that it's wonderful (I use it). It has its own much faster compiler, a language sensitive editor, a graphical class browser, a hierarchy editor, and a fully graphical symbolic debugger. If you haven't used Symantec's IDE (for example, their C++), you're in for a treat. It's similar to the IDE in Visual C++ and has some nice, unique features.

Just-In-Time Compiler

Symantec has also released a companion Just In Time Compiler, a replacement for the Java interpreter engine. The name is somewhat a misnomer. It is not a replacement compiler, it is a replacement interpreter. The name comes from the fact that the "interpreter" saves the machine code that results from bytecode interpretation and actually "peephole optimizes" it, like a smart C or Pascal compiler does. This can result in dramatic speed improvements, up to 10 to 1, over straight bytecode interpretation. The saved machine code is kept for re-use so the interpretation and optimization steps can be skipped after the first run, further increasing speed. Experiments with this technology at Sun showed that speed can be nearly the same as compiled and optimized C/C++.


[email protected]