Using an Integrated Development Environment Core Java

In this section, we show you how to compile a program with Eclipse, an integrated development environment that is freely available from http://eclipse.org. Eclipse is written in Java, but because it uses a nonstandard windowing library, it is not quiteas portable as Java itself. Never the less, versions exist for Linux, Mac OS X, Solaris,and Windows.

There are other popular IDEs, but currently, Eclipse is the most commonly used. Hereare the steps to get started:

  1. After starting Eclipse, select File -> New Project from the menu.
  2. Select “Java Project” from the wizard dialog. These screen shots were taken with Eclipse 3.2. Don’t worry if your version of Eclipse looks slightlydifferent.
  3. New Project dialog in Eclipse

    New Project dialog in Eclipse

  4. Click the “Next” button. Supply the project name “Welcome” and type in the fullpath name of the directory that contains Welcome.java.
  5. Configuring an Eclipse project

    Configuring an Eclipse project

  6. Be sure to uncheck the option labeled “Create project in workspace”.
  7. Click the “Finish” button. The project is now created.
  8. Click on the triangle in the left pane next to the project window to open it, and then click on the triangle next to “Default package”. Double-click on Welcome.java. You should now see a window with the program code.
  9. Editing a source file with Eclipse

    Editing a source file with Eclipse

  10. With the right mouse button, click on the project name (Welcome) in the left mostpane. Select Run -> Run As -> Java Application. An output window appears at the bottom of the window. The program output is displayed in the output window.

Running a program in Eclipse

Running a program in Eclipse

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 your code occasionally containsa typo (perhaps even a syntax error). Try it out—ruin our file, for example, by changing the capitalization of String as follows:

public static void main(string[] args)

Now, run the compiler again. You will get an error message that complains about an unknown string type. Simply click on the error message. The cursor moves to the matching line in the edit window, where you can correct your error. This behavior allows you to fix your errors quickly.

Error messages in Eclipse

Error messages in Eclipse

TIP: Often, an Eclipse error report is accompanied by a lightbulb icon. Click on the light bulbto get a list of suggested fixes.


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Core Java Topics