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 project code may not have warnings, including Javadoc warnings, when running the project
script on the lab computers. If you want your Eclipse to have similar compiler settings, import this configuration into your Eclipse workspace:
Note that it is not exactly the same—the project
script uses javac
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:
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:
- Code Conventions for the Java Programming Language, Revised April 1999.
However, these conventions are no longer maintained and major features have been introduced to Java since these were last updated. For a more modern guide, see:
- Google Java Style Guide, Updated May 2018.
I will use the Google style guide for all lecture code, as well as the homework and project templates. If you also want to use this code style, you can download the Eclipse settings and import them.
Otherwise, you can 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:
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 Source Code Pro Light, Roboto Mono Light, Anonymous Pro, and Incosolata. There are many fans of the customizable Input font as well.
-
Change your save actions (reference). I usually remove unused imports and fix indentation at least.
-
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: -
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. -
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.
-
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:
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.