Developer Forums | About Us | Site Map


Useful Lists

Web Host
site hosted by netplex

Online Manuals

Taming Tiger: Prerelease of Tiger
By John Zukowski - 2004-04-19 Page:  1 2 3 4

Using Tiger

You now have a full 1.5 release -- at least with what Sun provided with this early access release. To use the release, you'll need to add the installation directory to your path and change any related environment variables, as shown in Listing 1:

Listing 1. Setting Windows environment variables

    set JAVA_HOME=c:\j2sdk1.5.0-alpha
    set PATH=%JAVA_HOME%\bin;%PATH%

The first line sets the JAVA_HOME environment variable to where Tiger was installed. The second line says to add the bin directory under this installation directory to your path.

After setting the environment variables, you can run java -version to make sure you set everything properly, as shown in Listing 2:

Listing 2. Testing 1.5 environment
java -version
    java version "1.5.0-beta"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b31)
    Java HotSpot(TM) Client VM (build 1.5.0-beta-b31, mixed mode)

To try out the new release, we'll use the test code from last month's column. Grab the code and try compiling it without loading any special libraries. You'll need to compile the code with the -source 1.5 command-line switch. You'll find that there were some changes from the early access version to what made it to this alpha release, though who knows just what will hit the streets at beta time. For instance, just trying out the enumeration example reveals the VALUES constant is now a values() method, and it returns an array instead of a List. Also, the switch case labels changed to just the unqualified name as the constant. Listing 3 shows a modified EnumTest class from last month's examples (available in Resources):

Listing 3. Enumeration test

public class EnumTest {
  public static void main(String args[]) {
    enum Color {red, green, blue};

    // Get collection of values (as List)

    // Check if collection type is array of Color objects
    System.out.println(Color.values() instanceof Color[]);

    // Create variable of type for each value
    for (Color aColor : Color.values()) {

      // Use iteration in switch
      switch(aColor) {
        case red:
          System.out.println("Got red.");
        case green:
          System.out.println("Got green.");
        case blue:
          System.out.println("Got blue.");

Listing 4 shows the compilation step and running of Listing 3 (the -source 1.5 tag is only required at compile time):

Listing 4. Compiling and running example

  javac -source 1.5
  java EnumTest
    [red, green, blue]
    Got red.
    Got green.
    Got blue.

The true on line four of the output in Listing 4 indicates that the type returned by calling values() is of type Color[ ].

About that documentation

As I said before, there is no documentation. While I have yet to find anyone who's posted the 1.5 Javadoc on the Web, you can generate it yourself; see Resources) for a tip on how to use Ant for this purpose. Change the JDK_HOME in the build script (an example is provided in the source download in Resources) to where you installed the SDK, change PLATFORM_EXTENSION to exe for Windows, change JDK_MAJOR_VERSION to 1.5, and run Ant from where you created the build.xml file. This step will unzip the file that comes with the installation and run javadoc on the java, javax, and org packages.

Note: Give the program some time to run. It took approximately 17 minutes to run on my two-year-old machine, apart from the unzipping. Closing excess programs will help free up memory for it to run. Don't worry about any warning messages (I got close to 3000; at this point, we'll take what we can get).

We'll look at what's new in what this generates in future installments of this column (like the interface and new java.util.Queue collection). You'll find the generated Javadoc output in the new docs directory under the installation directory (JDK_HOME).

View Taming Tiger: Prerelease of Tiger Discussion

Page:  1 2 3 4 Next Page: Conclusion And Resources

First published by IBM developerWorks

Copyright 2004-2017 All rights reserved.
Article copyright and all rights retained by the author.