Eclipse is a free, powerful, open-source, and configurable IDE. I recommend you spend some time configuring Eclipse to meet your needs.
SSH Configuration
You will be accessing your private repositories on Github from Eclipse frequently. It helps if you setup your SSH keys with Github ahead of time to reduce the number of times you have to enter a username and password.
-
Follow the Github Generating a New SSH Key guide for your operating system to generate SSH keys for the first time. Before you start:
-
When prompted for a passphrase for your key, you can press Enter without entering anything. It is more secure to enter a passphrase, but less convenient. See the Working with SSH Key Passphrases guide from Github for more information.
-
Do NOT forget to complete the Add the SSH Key to Github step at the very end!
-
-
Follow the Github Testing Your SSH Connection guide from a CS lab computer to make sure everything is setup properly.
At this point, you should be able to clone, fetch, and push to your repositories from Eclipse without having to enter a password each time.
Sometimes, Eclipse does not know where your SSH keys are located. If you are running into issues, reach out to us on Piazza or office hours. We will help you with the setup.
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:
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:
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 my own personal code style for all lecture code, as well as the homework and project templates. 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:
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.