2.1 Download and Install the Java Software Development Kit (SDK)

2.1 Download and Install the Java Software Development Kit (SDK)

You probably have already installed the Java Platform, but if not, doing so should be your first step. Current versions of the servlet and JSP APIs require the Java 2 Platform (Standard EditionJ2SEor Enterprise EditionJ2EE). If you aren't using J2EE features like Enterprise JavaBeans (EJB) or Java Messaging Service (JMS), we recommend that you use the standard edition. Your server will supply the classes needed to add servlet and JSP support to Java 2 Standard Edition.

But what Java version do you need? Well, it depends on what servlet/JSP API you are using, and whether you are using a full J2EE-compliant application server (e.g., WebSphere, WebLogic, or JBoss) or a standalone servlet/JSP container (e.g., Tomcat, JRun, or Resin). If you are starting from scratch, we recommend that you use the latest Java version (1.4); doing so will give you the best performance and guarantee that you are compatible with future releases. But, if you want to know the minimum supported version, here is a quick summary.

  • Servlets 2.3 and JSP 1.2 (standalone servers). Java 1.2 or later.

  • J2EE 1.3 (which includes servlets 2.3 and JSP 1.2). Java 1.3 or later.

  • Servlets 2.4 and JSP 2.0 (standalone servers). Java 1.3 or later.

  • J 2EE 1.4 (which includes servlets 2.4 and JSP 2.0). Java 1.4 or later.

We use Java 1.4 in our examples.

For Solaris, Windows, and Linux, obtain Java 1.4 at http://java.sun.com/j2se/1.4/ and 1.3 at http://java.sun.com/j2se/1.3/. Be sure to download the SDK (Software Development Kit), not just the JRE (Java Runtime Environment)the JRE is intended only for executing already compiled Java class files and lacks a compiler. For other platforms, check first whether a Java 2 implementation comes preinstalled as it does with MacOS X. If not, see Sun's list of third-party Java implementations at http://java.sun.com/cgi-bin/java-ports.cgi.

Your Java implementation should come with complete configuration instructions, but the key point is to set the PATH (not CLASSPATH !) environment variable to refer to the directory that contains java and javac , typically java_install_dir /bin . For example, if you are running Windows and installed the SDK in C:\j2sdk1.4.1_01 , you might put the following line in your C:\autoexec.bat file. Remember that the autoexec.bat file is executed only when the system is booted .

 set PATH=C:\j2sdk1.4.1_01\bin;%PATH% 

If you want to download an already configured autoexec.bat file that contains the PATH setting and the other settings discussed in this chapter, go to http://www.coreservlets.com/, go to the source code archive, and select Chapter 2.

On Windows NT/2000/XP, you could also right-click on My Computer, select Properties, then Advanced, then Environment Variables . Then, you would update the PATH value and press the OK button.

On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/j2sdk1.4.1_01 and you use the C shell, you would put the following into your . cshrc file.

 setenv PATH /usr/j2sdk1.4.1_01/bin:$PATH 

After rebooting (Windows; not necessary if you set the variables interactively) or logging out and back in (Unix), verify that the Java setup is correct by opening a DOS window (Windows) or shell (Unix) and typing java -version and javac -help . You should see a real result both times, not an error message about an unknown command. Alternatively, if you use an Integrated Development Environment (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, compile and run a simple program to confirm that the IDE knows where you installed Java.

Core Servlets and JavaServer Pages (Vol. 1.Core Technologies)
Core Servlets and Javaserver Pages: Core Technologies, Vol. 1 (2nd Edition)
ISBN: 0130092290
EAN: 2147483647
Year: 2002
Pages: 194

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net