Java has long been thought of as a slow programming language unsuitable for real time applications such as games. Many years ago, in a millennia before this one that was correct, but those days are long gone. Massive improvements in both the Java virtual machine and computing power have created execution times on par with more traditional languages such as C++. Many people have also previously believed that Java is an internet-only language used for browser Applets. While this certianly is an area Java excells in and where it gained much of it's exposure, full blown applications have always been possible. Using current Java based technologies, you can write full screen, OpenGL 3D graphical programs using java in such a way that end users, regardless of their computer knowledge won't have a clue which programming language you used, nor will they care.
What does this mean? Well, basically if you prefer the portability of Java, it's comprehensive, well designed API's and the quality design that true O-O can give you, then you need not use a different language just for real time 3D application development. Just as one day C++ became suitable for game development after years of it being considered "too slow" in comparison to C, Java is now reaching this stage.
Several Java technologies have emerged to make 3d game creation possible. The way Java can achieve equal 3D graphics power as C++ is simple - it uses the same hardware accelleration graphics libraries like OpenGL. Using OpenGL in Java has been possible for several years now using the Java bindings provided in the library GL4Java. Recentally however, a new binding has jogbeen created as a community driven project, managed by several Sun programmers. Named JOGL (Java bindings for OpenGL), it provides several advantages such as using the New I/O (NIO) library of Java 1.4 for enhanced speed and also has better encapsulation than GL4Java. Two other libraries JOAL (Java bindings for OpenAL) and JInput are also being developed along side JOGL to cater for sound an input needs.
Another popular API is the Light Weight Java Gaming Library (LWJGL). It also provides an efficient OpenGL binding and has an impressive feature in that it doesn't depend on Sun's AWT library for windowing, but has it's own native windowing system. This is an excellent choice for those not wanting to be tied to this library, or wish to be able to create a native executable file (.exe) by using an ahead of time Java compiler such as JET. Other aspects of game development such as Input and Sound are also handled by LWJGL (LWJGL also contains bindings for OpenAL).
LWJGL and the JOGL/JOAL/JInput collection each provide a comprehensive gaming and real time application solution for Java. While similar, each caters for a different set of requirements with some overlap so new projects should consider both alternatives. A growing community is developing that uses, enhances and supports these projects. This new breed of Java Gaming Libraries ship with the non-restrictive BSD license meaning that the souce code is totally open and it is well suited to both commercial and community projects (as enhancements that are made can be given back to the community or kept as closed source).
The signs are already very impressive. There are several completed commercial and non-commercial 3D Java games and many more in the pipeline. Several middleware libraries to spare the programmer from the complexities of OpenGL are also very activly being developed.
It is said that a picture is worth a thousand words, and in this case it most certianly is. View the images that I have included in this article to see some of the works people have created using Java and the 3D technologies discussed in this article.References
- JOGL - Java for OpenGL
- JOAL - Java for OpenGL
- LWJGL - Light Weight Java Gaming Library
- Xith3D - 3D scenegraph, modelled on the Java3D API