Java Programing

May 27, 2007

source code by making it conditional on a

Filed under: Java Programming — webmaster @ 6:15 am

source code by making it conditional on a constant (in Java, a variable declared to be static and final). The Java compiler is smart enough to remove this code when it determines that it won’t be called. Java provides a well-defined package structure for organizing class files. The package system allows the compiler to handle most of the functionality of the make utility (a sophisticated tool for building executables from source code). The compiler also works with compiled Java classes, because all type information is preserved; there is no need for header files. All of this means that Java code requires little context to read. Indeed, you may sometimes find it faster to look at the Java source code than to refer to class documentation. Java replaces some features that have been troublesome in other languages. For example, Java supports only a single inheritance class hierarchy, but allows multiple inheritance of interfaces. An interface, like an abstract class in C++, specifies some of the behavior of an object without defining its implementation, a powerful mechanism borrowed from Objective C. It allows a class to implement the behavior of the interface, without needing to be a subclass of anything in particular. Interfaces in Java eliminate the need for multiple inheritance of classes, without causing the problems associated with multiple inheritance. As you’ll see in Chapter 4, Java is a simple, yet elegant, programming language. 1.4.2 Type Safety and Method Binding One attribute of a language is the kind of type checking it uses. When we categorize a language as static or dynamic we are referring to the amount of information about variable types that is known at compile time versus what is determined while the application is running. In a strictly statically typed language like C or C++, data types are etched in stone when the source code is compiled. The compiler benefits from having enough information to enforce usage rules, so that it can catch many kinds of errors before the code is executed, such as storing a floating-point value in an integer variable. The code doesn’t require runtime type checking, so it can be compiled to be small and fast. But statically typed languages are inflexible. They don’t support high-level constructs like lists and collections as naturally as languages with dynamic type checking, and they make it impossible for an application to safely import new data types while it’s running. In contrast, a dynamic language such as Smalltalk or Lisp has a runtime system that manages the types of objects and performs necessary type checking while an application is executing. These kinds of languages allow for more complex behavior, and are in many respects more powerful. However, they are also generally slower, less safe, and harder to debug. The differences in languages have been likened to the differences among kinds of automobiles.[1] Statically typed languages like C++ are analogous to a sports car reasonably safe and fast but useful only if you’re driving on a nicely paved road. Highly dynamic languages like Smalltalk are more like an offroad vehicle: they afford you more freedom, but can be somewhat unwieldy. It can be fun (and sometimes faster) to go roaring through the back woods, but you might also get stuck in a ditch or mauled by bears. [1] The credit for the car analogy goes to Marshall P. Cline, author of the C++ FAQ. Another attribute of a language is the way it binds method calls to their definitions. In an early- binding language like C or C++, the definitions of methods are normally bound at compile time, unless the programmer specifies otherwise. Smalltalk, on the other hand, is a late-binding language because it locates the definitions of methods dynamically at runtime. Early-binding is important for - 11

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

May 26, 2007

dynamic, interactive HTML-based applications. JavaScript draws its name

Filed under: Java Programming — webmaster @ 6:35 pm

dynamic, interactive HTML-based applications. JavaScript draws its name from its intended integration with Java. You can currently interact with Java applets embedded in HTML using JavaScript. There have been a few portable implementations of JavaScript that would promote it to the level of a general scripting language. For more information on JavaScript, check out Netscape’s web site (http://home.netscape.com). As we’ve already said, Java is similar in design to languages like Smalltalk and Lisp. However, these languages are currently used mostly as research vehicles, rather than for developing large- scale systems. One reason is that they never developed a standard portable binding to operating- system services, like the C standard library or the Java core classes. Smalltalk is compiled to an interpreted byte-code format, and it can be dynamically compiled to native code on the fly, just like Java. But Java improves on the design by using a byte-code verifier to ensure the correctness of compiled Java code. This verifier gives Java a performance advantage over Smalltalk because Java code requires fewer runtime checks. Java’s byte-code verifier also helps with security issues, something that Smalltalk doesn’t address. Smalltalk is a mature language, though, and Java’s designers took lessons from many of its features. Throughout the rest of this chapter, we’ll present a bird’s-eye view of the Java language. We’ll explain what’s new and what’s not-so-new about Java, how it differs from other languages, and why. 1.4 Safety of Design You have no doubt heard a lot about the fact that Java is designed to be a safe language. But what do we mean by safe? Safe from what or whom? The security features that attract the most attention for Java are those features that make possible new types of dynamically portable software. Java provides several layers of protection from dangerously flawed code, as well as more mischievous things like viruses and Trojan horses. In the next section, we’ll take a look at how the Java virtual machine architecture assesses the safety of code before it’s run, and how the Java class loader (the byte-code loading mechanism of the Java interpreter) builds a wall around untrusted classes. These features provide the foundation for high-level security policies that allow or disallow various kinds of activities on an application-by-application basis. In this section, though, we’ll look at some general features of the Java programming language. Perhaps more important than the specific security features, although often overlooked in the security din, is the safety that Java provides by addressing common design and programming problems. Java is intended to be as safe as possible from the simple mistakes we make ourselves, as well as those we inherit from contractors and third-party software vendors. The goal with Java has been to keep the language simple, provide tools that have demonstrated their usefulness, and let users build more complicated facilities on top of the language when needed. 1.4.1 Syntactic Sweet ‘n’ Low Java is parsimonious in its features; simplicity rules. Compared to C, Java uses few automatic type coercions, and the ones that remain are simple and well-defined. Unlike C++, Java doesn’t allow programmer-defined operator overloading. The string concatenation operator + is the only system- defined, overloaded operator in Java. All methods in Java are like C++ virtual methods, so overridden methods are dynamically selected at runtime. Java doesn’t have a preprocessor, so it doesn’t have macros, #define statements, or conditional source compilation. These constructs exist in other languages primarily to support platform dependencies, so in that sense they should not be needed in Java. Conditional compilation is also commonly used for debugging purposes. Debugging code can be included directly in your Java - 10

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

You may have heard that Java is a

Filed under: Java Programming — webmaster @ 7:10 am

You may have heard that Java is a lot like C or C++, but that’s really not true, except at a superficial level. When you first look at Java code, you’ll see that the basic syntax looks a lot like C or C++. But that’s where the similarities end. Java is by no means a direct descendant of C or a next- generation C++. If you compare language features, you’ll see that Java actually has more in common with languages like Smalltalk and Lisp. In fact, Java’s implementation is about as far from native C as you can imagine. The surface-level similarities to C and C++ are worth noting, however. Java borrows heavily from C and C++ syntax, so you’ll see lots of familiar language constructs, including an abundance of curly braces and semicolons. Java also subscribes to the C philosophy that a good language should be compact; in other words, it should be sufficiently small and regular so a programmer can hold all the language’s capabilities in his or her head at once. Just as C is extensible with libraries, packages of Java classes can be added to the core language components. C has been successful because it provides a reasonably featureful programming environment, with high performance and an acceptable degree of portability. Java also tries to balance functionality, speed, and portability, but it does so in a very different way. C trades functionality for portability; Java trades speed for portability. Java also addresses security issues, while C doesn’t. Java is an interpreted language, so it won’t be as fast as a compiled language like C. But Java is fast enough, especially for interactive, network-based applications, where the application is often idle, waiting for the user to do something or waiting for data from the network. For situations where speed is critical, a Java implementation can optimize performance with just-in-time compilation to byte-code, as previously discussed. Scripting languages, like Perl, Python, Tcl/Tk, and Wksh, are becoming very popular, and for good reason. There’s no reason a scripting language could not be suitable for safe, networked applications (e.g., Safe Tcl), but most scripting languages are not designed for serious, large-scale programming. The attraction to scripting languages is that they are dynamic; they are powerful tools for rapid prototyping. Some scripting languages, like awk and Perl, also provide powerful tools for text- processing tasks that more general-purpose languages find unwieldy. Scripting languages are also highly portable. One problem with scripting languages, however, is that they are rather casual about program structure and data typing. Most scripting languages (with a hesitant exception for Perl 5.0 and Python) are not object-oriented. They also have vastly simplified type systems and generally don’t provide for sophisticated scoping of variables and functions. These characteristics make them unsuitable for building large, modular applications. Speed is another problem with scripting languages; the high-level, fully interpreted nature of these languages often makes them quite slow. Java offers some of the essential advantages of a scripting language, along with the added benefits of a lower-level language. Incremental development with object-oriented components, combined with Java’s simplicity, make it possible to develop applications rapidly and change them easily, with a short concept-toimplementation time. Java also comes with a large base of core classes for common tasks such as building GUIs and doing network communications. But along with these features, Java has the scalability and software-engineering advantages of more static languages. It provides a safe structure on which to build higher-level networked tools and languages. However, don’t confuse Java with JavaScript! JavaScript is an object-based scripting language being developed by Netscape and others. It serves as a glue and an “in the document” language for - 9

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

May 25, 2007

Historically, interpreters have been considered slow, but because

Filed under: Java Programming — webmaster @ 9:20 pm

Historically, interpreters have been considered slow, but because the Java interpreter runs compiled byte-code, Java is a relatively fast interpreted language. More importantly, Java has also been designed so that software implementations of the runtime system can optimize their performance by compiling byte-code to native machine code on the fly. This is called just-in-time compilation. Sun claims that with just-in-time compilation, Java code can execute nearly as fast as native compiled code and maintain its transportability and security. There is only one true performance hit that compiled Java code will always suffer for the sake of security array bounds checking. But on the other hand, some of the basic design features of Java place more information in the hands of the compiler, which allows for certain kinds of optimizations not possible in C or C++. The latest twist in compilation techniques is a new virtual machine that Sun calls HotSpot. The problem with a traditional just-in-time compilation is that optimizing code takes time, and is extremely important for good performance on modern computer hardware. So a just-in-time compiler can produce decent results, but can never afford to take the time necessary to do a good job of optimization. HotSpot uses a trick called ” adaptive compilation” to solve this problem. If you look at what programs actually spend their time doing, it turns out that they spend almost all of their time executing a relatively small part of the code again and again. The chunk of code that is executed repeatedly may only be a small percent of the total program, but its behavior determines the program’s overall performance. To take advantage of this fact, HotSpot starts out as a normal Java byte code interpreter, but with a difference: it measures (profiles) the code as it is executing, to see what parts are being executed repeatedly. Once it knows which parts of the code are crucial to the performance, HotSpot compiles those sections and only those sections into true machine code. Since it only compiles a small portion of the program into machine code, it can afford to take the time necessary to optimize those portions. The rest of the program may not need to be compiled at all just interpreted saving memory and time. The technology for doing this is very complex, but the idea is essentially simple: optimize the parts of the program that need to go fast, and don’t worry about the rest. Another advantage of using an adaptive compiler at runtime is that it can make novel kinds of optimizations that a static (compile time only) compiler cannot dream of. 1.3 Java Compared with Other Languages Java is a new language, but it draws on many years of programming experience with other languages in its choice of features. So a lot can be said in comparing and contrasting Java with other languages. There are at least three pillars necessary to support a universal language for network programming today: portability, speed, and security. Figure 1.2 shows how Java compares to other languages. Figure 1.2. Programming languages compared - 8

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services

Compiled Java byte-code , also called J-code, is

Filed under: Java Programming — webmaster @ 10:15 am

Compiled Java byte-code , also called J-code, is executed by a Java runtime interpreter. The runtime system performs all the normal activities of a real processor, but it does so in a safe, virtual environment. It executes the stack-based instruction set and manages a storage heap. It creates and manipulates primitive datatypes, and loads and invokes newly referenced blocks of code. Most importantly, it does all this in accordance with a strictly defined open specification that can be implemented by anyone who wants to produce a Java-compliant virtual machine. Together, the virtual machine and language definition provide a complete specification. There are no features of Java left undefined or implementation-dependent. For example, Java specifies the sizes of all its primitive data types, rather than leave it up to each implementation. The Java interpreter is relatively lightweight and small; it can be implemented in whatever form is desirable for a particular platform. On most systems, the interpreter is written in a fast, natively compiled language like C or C++. The interpreter can be run as a separate application, or it can be embedded in another piece of software, such as a web browser. All of this means that Java code is implicitly portable. The same Java application byte-code can run on any platform that provides a Java runtime environment, as shown in Figure 1.1. You don’t have to produce alternative versions of your application for different platforms, and you don’t have to distribute source code to end users. Figure 1.1. The Java runtime environment The fundamental unit of Java code is the class. As in other object-oriented languages, classes are application components that hold executable code and data. Compiled Java classes are distributed in a universal binary format that contains Java byte-code and other class information. Classes can be maintained discretely and stored in files or archives on a local system or on a network server. Classes are located and loaded dynamically at runtime, as they are needed by an application. In addition to the platform-specific runtime system, Java has a number of fundamental classes that contain architecture-dependent methods. These native methods serve as the gateway between the Java virtual machine and the real world. They are implemented in a natively compiled language on the host platform. They provide access to resources such as the network, the windowing system, and the host filesystem. The rest of Java is written entirely in Java, and is therefore portable. This includes fundamental Java utilities like the Java compiler and Sun’s HotJava web browser, which are also Java applications and are therefore available on all Java platforms. - 7

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

May 24, 2007

They decided to start from scratch, and Gosling

Filed under: Java Programming — webmaster @ 11:31 pm

They decided to start from scratch, and Gosling began working on something he dubbed “C++ minus minus.” With the foundering of the Apple Newton, it became apparent that the PDA’s ship had not yet come in, so Sun shifted FirstPerson’s efforts to interactive TV (ITV). The programming language of choice for ITV set-top boxes was the near ancestor of Java, a language called Oak. Even with its elegance and ability to provide safe interactivity, Oak could not salvage the lost cause of ITV. Customers didn’t want it, and Sun soon abandoned the concept. At that time, Joy and Gosling got together to decide on a new strategy for their language. It was 1993, and the explosion of interest in the Internet, and the World Wide Web in particular, presented a new opportunity. Oak was small, robust, architecture-independent, and object-oriented. As it happens, these are also the requirements for a universal, network-savvy programming language. Sun quickly changed focus, and with a little retooling, Oak became Java. 1.1.2 Future Buzz? It would not be overdoing it to say that Java has caught on like wildfire. Even before its first official release, while Java was still a non-product, nearly every major industry player jumped on the Java bandwagon. Java licensees included Microsoft, Intel, IBM, and virtually all major hardware and software vendors. (That’s not to say that everything has been coming up roses. Even with all of this support Java has taken a lot of knocks and had some growing pains during its first few years.) As we begin looking at the Java architecture, you’ll see that much of what is exciting about Java comes from the self-contained, virtual machine environment in which Java applications run. Java has been carefully designed so that this supporting architecture can be implemented either in software, for existing computer platforms, or in customized hardware, for new kinds of devices. Sun and other industry giants are producing fast Java chips and microprocessors tailored to run media- rich Java applications. Hardware implementations of Java could power inexpensive network terminals, PDAs, and other information appliances, to take advantage of transportable Java applications. Software implementations of Java are available now for portable computing devices like the popular Palm PDA. Many people see Java as part of a trend toward cheap, Internet-based, “operating system-less” appliances that will weave the Net into more and more consumer-related areas. The first attempts at marketing “network computers” as alternatives to the standard PC have not gone very well. (The combination of Windows and cheap PC hardware form a formidable barrier.) But the desktop is only one corner of the network. Only time will tell what people will do with Java, but it’s probably worth at least a passing thought that the applet you write today might well be running on someone’s wristwatch tomorrow. If that seems too futuristic, remember that you can already get “smart cards” and “wearable” devices like rings and dog tags that have Java interpreters embedded in them. These devices are capable of doing everything from financial transactions (paying a hotel bill) to unlocking a door (the door to your hotel room) to rerouting phone calls (so your hotel room receives your business calls). The hardware is already here; it can’t be long before the rest of the software infrastructure begins to take advantage of it. A Java wristwatch is not a silly notion. 1.2 A Virtual Machine Java is both a compiled and an interpreted language. Java source code is turned into simple binary instructions, much like ordinary microprocessor machine code. However, whereas C or C++ source is refined to native instructions for a particular model of processor, Java source is compiled into a universal format instructions for a virtual machine. - 6

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services

executable code. Java addresses the issues raised here

Filed under: Java Programming — webmaster @ 1:36 pm

executable code. Java addresses the issues raised here and may help us start building the kinds of applications we want. Initially, most of the enthusiasm for Java centered around its capabilities for building embedded applications for the World Wide Web; these applications are called applets. Applets could be independent programs in themselves, or sophisticated frontends to programs running on a server. More recently, interest has shifted to other areas. With Java 2, Java has the most sophisticated toolkit for building graphical user interfaces; this development has allowed Java to become a popular platform for developing traditional application software. Java has also become an important platform for server-side applications, using the servlet interface, and for enterprise applications using technologies like Enterprise JavaBeans . And Java is the platform of choice for modern distributed applications. This book shows you how to use Java to accomplish real programming tasks, such as building networked applications and creating functional user interfaces. There’s still a chapter devoted to applets; they may become more important again when the Java 2 (and subsequent) versions of the Java platform are more widely distributed in web browsers. 1.1.1 Java’s Origins The seeds of Java were planted in 1990 by Sun Microsystems patriarch and chief researcher, Bill Joy. Since Sun’s inception in the early ’80s, it has steadily pushed one idea: “The network is the computer.” At the time though, Sun was competing in a relatively small workstation market, while Microsoft was beginning its domination of the more mainstream, Intel-based PC world. When Sun missed the boat on the PC revolution, Joy retreated to Aspen, Colorado, to work on advanced research. He was committed to accomplishing complex tasks with simple software, and founded the aptly named Sun Aspen Smallworks. Of the original members of the small team of programmers assembled in Aspen, James Gosling is the one who will be remembered as the father of Java. Gosling first made a name for himself in the early ’80s as the author of Gosling Emacs, the first version of the popular Emacs editor that was written in C and ran under Unix. Gosling Emacs became popular, but was soon eclipsed by a free version, GNU Emacs, written by Emacs’s original designer. By that time, Gosling had moved on to design Sun’s NeWS window system, which briefly contended with the X Window System for control of the Unix graphical user interface (GUI) desktop in 1987. While some people would argue that NeWS was superior to X, NeWS lost out because Sun kept it proprietary and didn’t publish source code, while the primary developers of X formed the X Consortium and took the opposite approach. Designing NeWS taught Gosling the power of integrating an expressive language with a network- aware windowing GUI. It also taught Sun that the Internet programming community will refuse to accept proprietary standards, no matter how good they may be. The seeds of Java’s remarkably permissive licensing scheme were sown by NeWS’s failure. Gosling brought what he had learned to Bill Joy’s nascent Aspen project, and in 1992, work on the project led to the founding of the Sun subsidiary, FirstPerson, Inc. Its mission was to lead Sun into the world of consumer electronics. The FirstPerson team worked on developing software for information appliances, such as cellular phones and personal digital assistants (PDAs). The goal was to enable the transfer of information and real-time applications over cheap infrared and packet-based networks. Memory and bandwidth limitations dictated small and efficient code. The nature of the applications also demanded they be safe and robust. Gosling and his teammates began programming in C++, but they soon found themselves confounded by a language that was too complex, unwieldy, and insecure for the task. - 5

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

Chapter 1. Yet Another Language? The greatest challenges

Filed under: Java Programming — webmaster @ 12:46 pm

Chapter 1. Yet Another Language? The greatest challenges and most exciting opportunities for software developers today lie in harnessing the power of networks. Applications created today, whatever their intended scope or audience, will almost certainly be run on machines linked by a global network of computing resources. The increasing importance of networks is placing new demands on existing tools and fueling the demand for a rapidly growing list of completely new kinds of applications. We want software that works consistently, anywhere, on any platform and that plays well with other applications. We want dynamic applications that take advantage of a connected world, capable of accessing disparate and distributed information sources. We want truly distributed software that can be extended and upgraded seamlessly. We want intelligent applications like autonomous agents that can roam the Net for us, ferreting out information and serving as electronic emissaries. We know, to some extent, what we want. So why don’t we have it? The problem has been that the tools for building these applications have fallen short. The requirements of speed and portability have been, for the most part, mutually exclusive, and security has been largely ignored or misunderstood. There are truly portable languages, but they are mostly bulky, interpreted, and slow. These languages are popular as much for their high-level functionality as for their portability. And there are fast languages, but they usually provide speed by binding themselves to particular platforms, so they can meet the portability issue only halfway. There are even a few recent safe languages, but they are primarily offshoots of the portable languages and suffer from the same problems. 1.1 Enter Java The Java programming language, developed at Sun Microsystems under the guidance of Net luminaries James Gosling and Bill Joy, is designed to be a machine-independent programming language that is both safe enough to traverse networks and powerful enough to replace native - 4

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

May 4, 2007

CHAPTER 3 Getting started, Hello Java 3D! 3.1

Filed under: Java 3D Programming — webmaster @ 12:00 pm

Test your Java 3D installation by running the HelloUniverse Java 3D demo. First run from the command line by going to the relevant installation directory and then typing: java HelloUniverse You can test the Java 2 plug-in installation by double-clicking the HelloUniverse_plug-in.html file. Your web browser should launch, the Java 2 plug-in window will appear, and the HelloUniverse applet should start. Once the tests are running you can safely delete the c:program filesjavasoft directory. 3.1.3 Documentation Java 3D programming involves general Java programming, high-performance programming, 3D graphics algorithms, 2D graphics programming, UI design, and many other issues. A good reference library or collection of electronic bookmarks will save you a lot of time and help you to avoid some of the pitfalls that have befallen your predecessors. Though far from exhaustive, the list of references which follows should give you some indication of fruitful areas to start researching. Java 2 SDK JavaDoc and reference books Java 2 is a complex technology. If you are going to write good Java 3D code you are going to require the latest Java 2 documentation and some good reference books. Swing reference book If you are developing an application that uses Swing (JFC) for the UI you will want to get a good Swing reference book. These weighty tomes can save you a lot of time during development. A good place to start is Swing by Mathew Robinson and Pavel Vorobiev (http://www.manning.com/Robinson/index.html). Java 3D JavaDoc Of course you should ensure that you download the latest API documentation for Java 3D. Sun collateral Java 3D tutorial The free Java 3D tutorial from Sun makes a good reference for many introductory topics and for those that like a structured tutorial style book to get started. Find it at http://www.javasoft.com/products/java-media/3D/collateral/. J3D.ORG You should check the J3D.ORG web site (http://www.j3d.org/) for FAQs and free example code. Many of the questions and problems that you run into have been faced and answered by other Java 3D users. Many answers are posted on the J3D.ORG web site or in the interest email list archives. J3D.ORG also contains useful utility code, tutorials, and examples that have been contributed by the active Java 3D community. Java 3D interest email list You should subscribe to this excellent forum (http://archives.java.sun.com/archives/java3d-interest.html) for asking fellow developers questions. Before posting your questions, take the time to search the archives for similar questions and answers. Java 3D user interface reference Building Java 3D User Interfaces by Jon Barrilleaux from Manning Publications will be very useful if you are building a complex 3D user interface. Jon answers many of the questions you will run into as you try to use 3D overlays, and presents solutions for the common UI requirements. For more information, surf to http://www.manning.com/Barrilleaux/index.html. There are several other Java 3D books coming into print check the J3D.ORG web site for the latest information. 3D graphics reference books If you are new to 3D graphics in general, you may want to pick up a good textbook on the subject. A good reference will cover the general aspects of 3D projections, transformation matrices, clipping, lighting, and rendering. Computer Graphics: Principles and Practice in C by James D. Foley, et al. (Addison-Wesley, 1995) is considered by many to be the bible of computer-generated 3D graphics. Many other useful books are reviewed in appendix B. 31

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services

CHAPTER 3 Getting started, Hello Java 3D! 3.1

Filed under: Java 3D Programming — webmaster @ 12:00 pm

CHAPTER 3 Getting started, Hello Java 3D! 3.1 Installation 3.2 Your first Java 3D application 3.3 Exercises for the reader 3.4 Summary Now the fun begins. It s time to begin conquering the Java 3D development environment, setting ourselves up for serious Java 3D fun in the chapters to come. I ll introduce a realistic Java 3D application to test your configuration, and allow you to experiment with some of the features described in later chapters. You ll look at a simple Java 3D example, SimpleTest, that illustrates building an AWT-based Java 3D application. The SimpleTest example uses the Sun utility classes MainFrameand SimpleUniverse(included with your Java 3D distribution) to hide some of the complexities that we will be delving into in the chapters to come. 3.1 Installation Our first step, obviously, is to install everything we need for Java 3D development. Refer to appendix B and the bibliography for useful sources of information or additional help. 3.1.1 Java 2 SDK Check the Sun web site (http://java.sun.com) and download the latest release. Java 2 SDK 1.3.1 (JDK 1.3.1) is the latest release at the time of print. You can also find it at http://www.javasoft.com/j2se/1.3/. Remove all previous versions of the SDK, JDK, or JRE prior to installing the new SDK. After installation launch the Java plug-in control applet from the Windows Control Panel and set the Java Runtime Environment (JRE) to the newly installed SDK location. This will enable running Java 3D applets using the Java 2 plug-in. 3.1.2 Java 3D 1.2 JDK Download the latest release of the Java 3D SDK at http://www.javasoft.com/products/java-media/3D/index.html. The OpenGL version of Java 3D has historically been more stable and ahead of the DirectX release in terms of features. At the time of print the latest release is Java 3D 1.2.1. You should install Java 3D into the same directory as the Java 2 SDK, typically c:jdk1.3. This will ensure that all your Java 2 demo applications are installed into the same place. You can then use REGEDIT to edit the Windows registry to remove all references to the JRE installation directory (which is also installed when you install the SDK). Replace all occurrences of c:program filesjavasoftjre1.3 with the SDK installation location, usually c:jdk1.3jre This will enable running the Java 3D demos from the command line, and ensure that only one Java 2 runtime environment is installed on your machine. Do not run REGEDIT unless you are an experienced Windows user and IMPORTANT familiar with editing the registry. It is not strictly necessary to remove all references to the JRE install location. 30

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services

« Previous PageNext Page »

Powered by Java Web Hosting