6.031
6.031 — Software Construction
Spring 2018

Technical Tips & Troubleshooting

I messed up my Eclipse and it doesn’t show all the things it used to show.

Open Perspective, Java, Debug

First, make sure you are in the Java perspective: in the top right corner of the window, click the Open Perspective toolbar button and select Java.

If your Java perspective doesn’t look right, go to WindowReset Perspective to return to the Eclipse defaults.

I can’t login to one or more 6.031 web servers (e.g. javatutor.csail.mit.edu, clicker.csail.mit.edu, 6031.mit.edu, didit.csail.mit.edu, omni.csail.mit.edu).

First just try restarting your browser, so that the web server asks you to present your certificate again. That often fixes a temporary hiccup.

Next check whether your MIT certificate is valid using the certificate test page.

Then try a different web browser: Chrome, Firefox, Safari. You may have to install your certificate in the new browser.

Are you using Windows with an antivirus checker turned on? Sometimes antivirus interferes with SSL connections and causes SSL_PROTOCOL_ERROR in every browser. Try turning off your antivirus checking temporarily to see if it fixes the problem. If so, then look for a way to add the web server to a whitelist in your antivirus configuration.

When I see the name of a variable or method or class in Eclipse, how can I jump straight to its definition?

Command-click (Mac) or Control-click (Windows/Linux) on the name, and Eclipse will jump to its definition.

After a jump like that, how can I go back to where was before?

Navigate → Back, which might have the keyboard shortcut Alt ⟵ or Command [.

Eclipse’s Navigate Back and Forward are analogous to the back and forward buttons in your web browser.

How can I search for a file or a class by name?

Navigate → Open Resource brings up a dialog for quickly searching for and jumping to a file, which is a resource in Eclipse terminology. Its keyboard shortcut is Command-Shift-R or Control-Shift-R.

Navigate → Open Type brings up a similar dialog for types (classes and interfaces). The shortcut is Command-Shift-T or Control-Shift-T.

Editing in Eclipse

How can I easily rename a variable or method or class?

Enter new name, press return to refactor

Put your cursor on the name and use Refactor → Rename (or its keyboard shortcut) to rename that variable, method, or class in all the places it appears.

How can I automatically reformat and reindent my code?

Use Source → Format to clean up your act.

How can I replace tab characters with spaces?

After you have set up Eclipse, Source → Format will change any tabs you have lying around into spaces. You can right-click the package to de-tab all of your classes at once.

How can I easily comment and uncomment parts of my code?

Use Source → Toggle Comment to quickly toggle on or off some lines of code. The keyboard shortcut is Command / or Control /.

How can I get Eclipse to manage the package import statements automatically?

Use Source → Organize Imports to automatically add and organize Java import statements. Just start using a new class, Organize Imports, and you’re good to go. The keyboard shortcut is Command-Shift-O or Control-Shift-O.


Please post on Piazza to suggest more Eclipse resources or tips and tricks we might include.

Have fun in 6.031!