CS 272 Software Development

CS 272-01, CS 272-02 • Spring 2023

Canvas GitHub Piazza Live Polls

Configuring Eclipse

Eclipse is a free, powerful, open-source, and configurable IDE. I recommend you spend some time configuring Eclipse to meet your needs.

Compiler Configuration

The homework and project code should not have warnings, including Javadoc warnings. If you want your Eclipse to have similar compiler settings, import this configuration into your Eclipse workspace:

https://gist.github.com/sjengle/c7d572a4d0eaf0be618f95d761d49a08

To use the above configuration, scroll to the “view raw” link and open it in a new window. Save the output as eclipse-compiler-settings.epf to your system. (Alternatively, copy and paste the text into a file with this name.)

In the Eclipse Preferences view, click the “Import” button near the bottom left and select the epf file. Or, follow these steps to import the epf Eclipse preferences file. Follow the prompts to import the compiler settings.

Note that it is not exactly the same—the autograding feature uses the javac compiler and Eclipse uses its own built-in Java compiler instead.

Javadoc Configuration

Your code should have proper Javadoc comments for all members and methods before requesting a code review. To receive warnings when you are missing something (or something is out of date) with your Javadoc comments, use these settings:

Javadoc

If you imported the compiler settings from before, this should already be configured for you!

Code Formatting

Your code should always be consistently formatted, especially before requesting a code review. The exact style you adopt is up to you. The official Java code conventions are at:

However, these conventions are no longer maintained and major features have been introduced to Java since these were last updated. For more modern guides, see:

You can also customize the formatter to your own preferences. You can use these settings to change the brace style, where newlines and spaces are used, and fix how Eclipse formats try-with-resources code blocks. For example:

Java Code Formatter

You can further customize Eclipse to re-format your code every time you save. See below for details.

Other Customization (Optional)

I recommend you customize other features in Eclipse as well. For example:

  • Change the fonts used in the editor (reference). You can find several options on Google Fonts. My favorites are Fira Code (not Fira Mono), Source Code Pro Light, Roboto Mono Light, Anonymous Pro, and Incosolata. There are many fans of the customizable Input font as well.

    Colors and Fonts

    Fonts like Fira Code have some fancy ligatures so the combination of characters like < and = turn into <= when viewed. If you copy and paste <= elsewhere, you’ll see that it is stored as the two separate characters < and = (just displayed as if they were one).

  • Change your save actions (reference). I usually remove unused imports and fix indentation at least.

    Save Actions

  • Customize the autocomplete code templates (reference, examples). I usually create one for printf myself. You can download the templates I use and import them into your Eclipse workspace:

    Templates

  • Change the layout and add different views. I usually add the Tasks view, which shows me all of my TODO comments. I also prefer to add the Git views to my Java perspective rather than switching to the Git perspective.

    Views

  • Customize the visibility of whitespaces in the text editor (reference). This can be helpful to detect when a mix of tabs and spaces are used for indentation.

    Whitespace

    Whitespace

  • Change how content assist works for the Java editor (reference). If you find Eclipse inserting code automatically when you do NOT want it to, you might consider changing the “Disable insertion triggers” setting:

    Content Assist

The official guides for Eclipse are located at:

Keep in mind that Eclipse is under active development, and bugs happen.

Try to close projects in Eclipse when you are no longer working on them. This can improve performance.