6.031 — Software Construction
Spring 2020

Technical Tips and Troubleshooting

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

First, make sure you are in the Java perspective: in the top right corner of the window, click the Java Perspective toolbar button, which looks like Java Perspective toolbar button.

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

I can’t log in to a 6.031 web site.

6.031 systems use Touchstone to log you in, which allows you to either use a browser certificate (the most convenient method) or type your Kerberos password.

First just try restarting your browser. That often fixes a temporary hiccup.

Next try a different web browser: Chrome, Firefox, Safari.

Try deleting your browser’s cookies associated with the site you’re trying to log into.

Try using your Kerberos password instead of a browser certificate. If the password works and the certificate does not, you probably need fresh certificates.

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.

If all else fails, please post privately on Piazza and include the URL you tried to visit, whether you were able to log in with 2-factor authentication, and any error information.

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. Right-clicking and choosing Open Declaration does the same thing.

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

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

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

Right-click 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 autocomplete a class name, method name, or variable name?

Type the first part of the name, then use Control‑Space to see possible completions.

How can I generate a method stub (method signature and empty body) for an interface or superclass method?

Put your cursor where you would create the method, and use Control‑Space to see a list of methods you might override or implement.

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?

First, make tab characters visible using Window → Editor → Show Whitespace Characters. The editor should now display every space as · and every tab as ».

After you have set up Eclipse using the 6.031 configuration, 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.

If your 6.031 Eclipse workspace is misconfigured, then try running Help → Perform Setup Tasks to reapply the configuration to your workspace, then try reformatting your code again.

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!