Before you can work with J2EE 1.4 SDK, you need to make sure it is set up correctly. This article, the first of two parts, will help you do that. The second part will take you through writing a simple application. It is excerpted from chapter two of the book Beginning J2EE 1.4 From Novice to Professional, written by James L. Weaver, Kevin Mukhar, and Jim Crume (Apress, 2005; ISBN: 1590593413).
Getting Set with J2EE - Installing the J2EE 1.4 SDK (Page 2 of 4 )
This chapter assumes that youre running Windows 2000 Professional or XP Professional. The J2EE 1.4 SDK does not support earlier versions of Windows. The Sun web site (http://java.sun.com/j2ee) has installation details of other supported operating systems (Solaris SPARC 8 & 9, and RedHat Linux 7.2).
Installing the J2EE 1.4 SDK couldn't be much easier. As we saw in Chapter 1, the J2EE environment is based on the Java 2 Standard Edition platform, so you need to have that installed before following the steps described in this chapter. Youll need to ensure that you've got the Java Development Kit for J2SE (Java Standard Edition) 1.4 (or later) installed. If you've got an earlier JDK, you need to update it. If you're not certain which version of Standard Edition you have, you can try running the J2EE SDK 1.4 installation anyway. If you don't have the correct version of J2SE installed, you'll see a warning message, and have to abort the installation. You should then install the correct version of the J2SE SDK and run the J2EE SDK installation again.
Alternatively, you can simply go to a command line prompt and type java version at the command prompt. The Java interpreter should print out the version information:
> java version java version "1.4.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92) Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
The version listed in the first line should be at least 1.4.0.
Problems and Solutions
Java version is lower than 1.4.0
Obtain and install the latest version of the J2SE SDK. You may want to uninstall the older version before installing the newer version. (you don't have to, but unless you have some compelling reason to keep it around, it's just dead weight).
returns the message:java version
The J2SE SDK is not installed, or the PATHenvironment variable does not include the path to the java executables.
java is not recognized as an internal or external command, operable program or batch file.
Check thePATH, and correct the problem, or reinstall the J2SE SDK.
Once you've done that, installing J2EE is a breeze--just run the installation program. The installation program will firstly check to make sure youve got the right version of the J2SE SDK. Then, make a note of where you're installing the J2EE SDK on your system--you'll need to know that path after the installation is complete in order to update and add some environment variables.
Environment variables are used by the Windows operating system as a shortcut to selected directories on your system. You can set either user-specific environment variables, or (provided youre logged in as a user with administrative rights) system-wide environment variables. Once you set an environment variable for your Java installation, you will find it much quicker and easier to compile and run your Java applications from the command line, as youll see shortly.
Once the installation is complete, it's time to set up the environment variables you'll need to run the examples in this book. You can check and set these from the System properties. From the Control Panel, choose the System applet. Select the Advanced tab and click on Environment Variables:
When you click the Environment Variables button, a dialog will allow you to check and set the values for environment variables:
Make sure that the following environment variables are set either in your local user variables, or in the system variables. If they don't already appear in the list, you can add them by clicking the New button. If they need to be modified, edit them by clicking the Edit button. Click OK when you've finished.
Contains the path to the directory where J2SE is installed, for example: c:\j2sdk1.4
Contains the path to the directory where J2EE SDK is installed, for example: c:\Sun\AppServer
This should include the path to the bindirectories of the J2SE SDK and the J2SDKEE. For example: c:\j2sdk1.4\bin;c:\Sun\AppServer\bin;...
You can alternatively use theJAVA_HOMEandJ2EE_HOMEenvironment variables in your path to make things a little simpler, for example: %JAVA_HOME%\bin;%J2EE_HOME%\bin;...
Note that the system will search through for executable files using the PATH variable, starting with the directories that appear first in the path. In order to ensure that there aren't other versions of the J2SE or J2EE interfering on this machine, make sure that these new entries go at the front of the PATH variable.