Sun Java
From Software By Jeff
It all starts with the Java Software Development Kit, or SDK. Most computers have a version of Java installed, especially if the users have been web browsing for some time. This is usually a runtime environment, however, and not the environment necessare for developing software.
| Table of contents |
JDK Versions
The latest version of the JDK as of this writing is J2SE 5.0. The most common JDK in use out there, however, is still J2SE 1.4. What does this mean?
Java is, as all of our software is, a progressing language and technology. Currently we're in the second release of Java, the J2 in J2SE.
Java is released in a variety of forms. We are using the Standard Edition. The SE in J2SE. Other releases include the Enterprise Edition, or J2EE, and the Mobile Edition, or J2ME. Functionally, these editions represent a superset (more features) as in the case of J2EE or a subset (fewer features) as in the case of J2ME. They are all representations of the Java language, and when used correctly in the appropriate environment, all have the same powerful enticements that Java brings to our development.
One thing to note is that J2EE 5.0 is not available at this time. If you will be writing Java Enterprise Edition applications, you'll have to stick with version 1.4 for now.
The JDK is, as mentioned, the Java Development Kit. It comes with, in addition to other things, the compiler (javac) and package management (jar), optionally Java source (for debugging), and documentation (JavaDoc) for assistance while development. Strictly, in the case of one of our chosen IDEs, Eclipse, the JDK is not required for operation, however, because of the additional tools and additional debugging and documentation, we strongly encourage the use of a JDK.
Four our purposes we'll recommend using the fourth (1.4) or fifth (1.5) release of Java, if it's available for your platform.
It is important to note that Sun provides seven different releases. Included are releases for its Solaris Operating Environment (four of them for both Intel and Sparc, and both 32-bit and 64-bit versions), LINUX (32-bit and 64-bit AMD versions), and Windows (32-bit).
It does happen that a JDK is developed for an operating system by someone else. AIX is a fine example of this--IBM provides the JDK and JRE for AIX, not Sun. Microsoft also provides a version of the JRE for Windows. Apple provides a version of the JDK for its Mac operating system.
Finally, distributors of other software also package or create JDKs of their own. BEA is one that comes to mind, with its WebLogic product there is an incldued JDK, to ensure that their software works as expected. Oracle likewise provides a version of the JDK with their software. Since this is a commercial application, and we're all about Open Source Software in this document, we'll just leave it as a mention, to alert you to the other possible sources of getting the JDK.
Version 1.4 versus 5.0
The version of the JDK, whether the 5.0 or 1.4, is the iterative release of the J2SK JDK we'll be using. Although labeled 5.0, it is the next iteration, and until release was referred to as 1.5. In fact, if you execute "java -version" with the 5.0 version of the JDK, it will report version 1.5. This represents the latest in Java's released software from Sun.
The minor version numbers (i.e., J2SE 1.4.2) introduce very minor changes from the previous release, typically security or bug related fixes. Typically the differences in the features of the language are very small, and often do not require any code to be changed to support the minor version release.
The differences between 1.4 and 5.0, however, represent some tremendous opportunities for additional features. It happens that Java is happily backwards compatible, and that if you have code written and working with 1.2 and above, it should work well with both 1.4 and 5.0. You cannot, of course, expect code written using language features of a higher version to run on a runtime engine of a lower version.
Without going into the abundance of enhancements of 5.0, let us instead direct you to a discussion at Sun that introduces five good reasons (http://java.sun.com/developer/technicalArticles/J2SE/5reasons.html) to switch from earlier versions to 5.0.
Downloading and Installing
Visit Sun J2SE 5.0 JDK Download (http://java.sun.com/j2se/1.5.0/download.jsp) or Sun J2SE 1.4 JDK Download (http://java.sun.com/j2se/1.4.2/download.html) and check for the version for your operating system, and download it. Make sure to get the JDK. You'll have to agree to the license, which (do not take this as legal advise!) basically says you won't steal Java from Sun.
For our purposes, we'll assume the installation is from the Sun website. If you have the option, use this until you have good reason to do otherwise (i.e., on Mac, not much choice).
Once the download is completed, the installation is fairly straight forward, but does differ by operating system.
Installation on Microsoft Windows
Microsoft has an edge in installation, and installing the JDK is no different. The download will provide an executable that will prompt you for which features you wish to have installed, and for the installation location.
It is suggested that you use something easy to find, and reflective of the version installed. Something like C:\JDK1.4.2 will be recommended by the installation program, and should be followed.
Once the installation is complete, one or two tricks can be employed to ensure this JDK is the one used by the tools we're using here. Primarily, we need to ensure that our JDK is the only one in the system's executable search path, and that the system is alerted to the JDK's installation.
These are both done by looking into the System settings of the Control Panel. Depending on the version of Windows you run, this may differ a little. Since the 9x, ME, and NT versions are no longer supported by Microsoft, we'll leave that to you to discover. Likewise, since Windows 2000 is on the short list, we won't address it directly, however, its configuration is very much like Windows XP, which we will discuss.
Step by step, go to the Start menu, and select the Control Panel from the menu. When the Control Panel opens, find and double-click on the System applet's icon. When the System Properties window opens, click on the Advanced tab, then find and click on the Environment Variables button. Here you'll see two windows reperesenting the variables you can set. Depending on your permission settings you may not be able to affect the System variables in the lower window, but you can always affect the User variables in the upper window. In this window you need to create or modify the variable JAVA_HOME, providing as its value the path to your installation (in the example above, C:\JDK1.4.2). Additionally find or create a variable named PATH, and ensure that our JDK is the only one, or at least the first one in the list, making sure to include the bin directory (as in C:\JDK1.4.2\bin). That's it. The installer may have done this for you, but it pays to make sure.
You can test this by opening a command window, and from the prompt simply type "java -version" and you should be rewarded with the correct version number for your installation.
Installation on LINUX
The LINUX installation is a little less friendly, but no less straight-forward.
The download is available in two forms, a runnable RPM and an executable self-extracting file.
If your system supports RPMs, you have root access, and you're comfortable installing software this way, this is the route to go. The instructions from Sun are as simple as extracting the file, running your RPM manager on it, and finishing with your enviroment configuration.
- Extract the RPM from the dowloaded file (sh downloaded-filename.bin) and verify the existence of the .rpm file in the same directory
- Become root (if not already)
- Execute the RPM installation (rpm -iv extracted-filename.rpm)
If you're installing this as root, so that everyone accessing the system can use it, update the login configuration files to include the JDK bin directory and JAVA_HOME variables as discussed above for Windows, and below for LINUX.
If you do not have root access, or RPM access or comfort, the installation is just as straight-forward for the self-extracting file.
- Move the downloaded file to the directory in which you wish it to be installed (i.e., your home directory ~ or /usr/local for system-wide use, which does require root access on most systems)
- Extract the file (sh downloaded-filename.bin) and verify the existence of the JDK directory, which should have the name indicative of the version, i.e., j2sdk1.5.0.
- If the directory is in the wrong place (you extracted in your download, but want it in your home directory), simply move the directory to the right place
Then update the environment variables as appropriate to include the JDK bin directory in your path and the JAVA_HOME variable.
Installing on Solaris
The Solaris distribution, like the LINUX installation, is released in two forms, one a self-extracting script, and the other a set of packages for the package manager utilities.
For right now, review the installation pages at Sun's website (http://java.sun.com).
Having More Than One JDK
There are obvious reasons you might have more than one. It's almost silly to have more than one installation of the same version of the JDK, but it might happen anyway.
It does make sense, however, to have different versions of the software. Some valid reasons include migrating your software to the next version, as well as regression testing to ensure the software you write works with previous versions, even though you use a higher version in your environment.
For our purposes we'll stick with just one installation of the JDK. If you have more than one, we'll ignore that for now, and leave our discussions assuming only the one we've installed above.