Using an Integrated Development Environment
In this section, we show you how to compile a program with the Sun ONE Studio Community version, a free integrated development environment from Oracle. You can download your copy from http://www.oracle.com/software/sundev/jde. Sun ONE Studio is written in Java and should run under any platform that has a Java 2 runtime environment. Preconfigured versions exist for Solaris, Linux, and Windows. You can also get a more bleeding-edge open-source version from http://netbeans.org. After starting Sun ONE Studio, various toolbars and windows are loaded (see Screenshot-2).
Screenshot-2. Starting Sun ONE Studio
Select File -> Open File from the menu, then load CoreJavaBook/v1ch2/Welcome/Welcome.java. You will be asked if this file should be in the "default package." Click Accept. (See for more information on packages. For now, all our programs are in the default package.) You should now see a window with the program code (see Screenshot-3).
Screenshot-3. The edit window of Sun ONE Studio
Select Build -> Compile from the menu. Your program is compiled. If it compiles correctly, select Build -> Execute from the menu. The edit window goes away, and an output window appears at the bottom of the screen. The program output is displayed in the output window (see Screenshot-4).
Screenshot-4. The output window of Sun ONE Studio
To return to the edit window after the program is finished, click on the "Editing" tab at the top of the screen.
Locating Compilation Errors
Presumably, this program did not have typos or bugs. (It was only a few lines of code, after all.) Let us suppose, for the sake of argument, that you occasionally have a typo (perhaps even a bug) in your code. Try it out—ruin our file, for example, by changing the capitalization of String as follows:
string greeting = new String;
Now, run the compiler again. You will get error messages (see Screenshot-5). The first one complains about an unknown string type. Simply click on the error message. The cursor moves to the matching line in the edit window, and you can correct your error. This allows you to fix your errors quickly.
Screenshot-5. Error messages in Sun ONE Studio
To start a new program, select File -> New from Template from the menu. In the resulting dialog, open up the "doorlatch" labeled Classes by clicking on the icon. Then select Empty and click the Next button (see Screenshot-6).
Screenshot-6. Starting a new program in Sun ONE Studio
You will be asked if you want to add this file to the current project. Until you use projects in earnest, there is no harm in answering either Yes or No. Now you are ready to edit your new file, compile it, and run it. We will discuss the Sun ONE Studio debugger in .