One important step in creating your own computer games is configuring your development environment. Keep reading to learn how. This article is taken from chapter one of Advanced Java Game Programming by David Wallace Croft (Apress, 2004; ISBN 1590591232).
A good example is the best sermon. —Benjamin Franklin
In this chapter, you will learn how to configure your development environment to create your own games using the game library and examples described in this book.
Upgrading to 1.4
To compile and run the example games in this book, you need to download and install the Java 2 Software Development Kit (SDK), Standard Edition (J2SE), version 1.4 or later. “Java 2” refers to the Java 2 Platform. “Java 1.4” refers to the specific version of the Java 2 Platform. You can blame the marketing folks at Sun Microsystems for the confusion.
Version 1.4 is required because the game code depends upon new accelerated graphics classes in that version of the J2SE. These new classes greatly increase animation performance. At the time of this writing, J2SE v1.4 is available on multiple platforms including Linux, Mac OS X, Solaris, and Windows. If you do not have version 1.4 or later installed, you can download it from http://java.sun.com/ for the most common platforms besides Apple. Apple developers can download the latest version of Java from http://developer.apple.com/java/.
The game code should run without modification equally well on all platforms that support J2SE v1.4. Having said that, I must now warn you that I have only tested the code on Linux and Windows. I will depend upon the feedback of readers with Mac OS X and Solaris systems to let me know how the code fares on those platforms.
Sticking to the Core
The J2SE defines a standardized application programming interface (API) library with thousands of classes grouped into scores of packages that are considered core. The core classes are guaranteed to be pre-installed on any J2SE-compatible system. This makes the life of a developer much easier because it means less code that needs to be downloaded and installed to the client platform. An example of a core package is java.lang, which contains the basic classes needed in most Java programs.
Noncore classes are not guaranteed to be pre-installed on the target platform, so you will probably want to think twice before using them. These non-core classes are known as optional packages. Until recently, they were called standard extensions. They are “extensions” in that they are not distributed with the core, and they are “standard” in that they define standardized interfaces for additional capabilities independent of their underlying implementation. An example of an optional package is javax.media.j3d, a library for rendering a 3D scene graph.
It used to be that you could easily tell which packages were core and which were standard extensions because the core package names all started with the java prefix and the standard extension names all started with the javax prefix. This is no longer the case as the core now contains packages that start with names other than java such as javax.swing. I am not sure why Sun Microsystems changed this but I suspect it had something to do with the Microsoft lawsuit. I know that the switch continued to confuse even high-level Sun engineers for some time after the decision was made. At some point they will have to give the Java library a complete overhaul. Perhaps they will call it the Java 3 Platform, Version 2.0. When they do so, I hope they consider changing the package naming convention back to the way it was.
Most of the example game code relies upon the core classes exclusively. This ensures that they will run without additional installation steps on all J2SE platforms. A few of the games, however, do rely upon the optional packages. In these cases, I will warn you.
The subset of the J2SE for smaller platforms such as embedded devices is the Java 2 Micro Edition ( J2ME). The superset for heavy-duty platforms such as application servers is the Java 2 Enterprise Edition ( J2EE). This book does not cover J2ME and only covers J2EE lightly. Where you need to use J2EE code, I will forewarn you just as I will when you use optional packages.
This article is excerpted from Advanced Java Game Programming by David Wallace Croft (Apress, 2004; ISBN 1590591232). Check it out at your favorite bookstore today. Buy this book now.