Chapter 2. Java Development

This chapter is where we get down to the business of developing Java using Eclipse. We’re going to take a look at using Eclipse for Java development as well as project management, going from the basics to the fairly serious. Nearly everything in this chapter is essential knowledge for the Java developer using Eclipse, so let’s jump in.

Developing Java Code

If there’s anything that takes more time than it seems to be worth in Java, it’s creating code from scratch. While the logic inside a method, interface, or class is unique, the modifiers of a method, the imports for a class, and the syntax involved with new packages is the same over and over again. This often results in a lot of repetitive typing, wasted time, and in many cases, annoying little typo-related bugs. Eclipse can help with all this and more.

Creating New Methods

Eclipse—through code assist—makes it easy to create new methods. As an example, we’re going to create and call a new method named printer, which displays the message “No worries.”, as you can see in Example 2-1.

Example 2-1. The Ch02_01.java example
public class Ch02_01
{
    public static void main(String[] args)
    {
        printer( );
    }

    private static void printer( )
    {
        System.out.println("No worries.");
    }
}

How do you create new methods? Start Eclipse now and create a new project named Ch02_01. Then create a new Java class named Ch02_01, making it part of the org.eclipsebook.ch02 package. Leave the checkbox for the creation of a stub for the main ...

Get Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.