CSC300: Eclipse Problems

Contents [0/6]

The most common problem with eclipse [1/6]
The second most common problem with eclipse [2/6]
What to do you have lots of red marks in Eclipse [3/6]
What to do if you cannot see package explorer in Eclipse [4/6]
No files? Run problems? [5/6]
About the code from the textbook [6/6]

(Click here for one slide per page)


The most common problem with eclipse [1/6]

If eclipse has lots of errors like these:

module-info-errors

Then delete the file module-info.java.

module-info-fix

Afterwards, select Project > Clean... > Clean All Projects > Clean

The second most common problem with eclipse [2/6]

The most common problem with eclipse is that the compiler compliance level gets messed up. Try this. If it does not work, then contact me.

With the compliance level issue, you may get a lot of compiler errors, such as this:

eclipse-common1

To fix it, pull up eclipse preferences. On windows, this is under the window menu.

eclipse-common2

Navigate to the compiler pane so that you can see the compliance level.

eclipse-common3

If the compliance level is anything other than 17, set it to 17 and then save and follow the prompts to recompile your entire workspace. It will take a few seconds.

eclipse-common4

If the compliance level is already correct, then set it to 1.4, and then save and follow the prompts to recompile your entire workspace. Then repeat the process and set it back to 17.

This appears to be a bug in eclipse. Good news is that is it seems to happen at most once with students in this class.

If this did not fix your issue, contact me.

What to do you have lots of red marks in Eclipse [3/6]

Suppose you had eclipse working and then one day, eclipse looks like this:

install-eclipse-red

Try

  "Project" > "Clean..." > "Clean all projects"

If that does not work, try deleting potentially problematic files to re-create a fresh eclipse-workspace:

What to do if you cannot see package explorer in Eclipse [4/6]

To show the package explorer, do this:

package-explorer1

Once it is showing, you can adjust the view using the buttons:

package-explorer2

No files? Run problems? [5/6]

You may see that the algs4 project is empty, like this:

eclipse-no-algs4

You may get this Run As box in eclipse, like this:

install-run1

Or this:

install-run2

This means that the algs4 project is not initialized properly. Here are some steps:

About the code from the textbook [6/6]

The textbook code is written to run from the command line. We will not do this. Instead, we will edit the code in eclipse to provide the following, when necessary:

  1. command line arguments
  2. standard input
  3. standard output

If the text runs the program:

  java Program arg1 arg2 < input.txt > /tmp/output.txt

We will add the following lines to the "main" method of our java program:

  public static void main(String[] args) {
    args = new String[] { "arg1", "agrg2" };
    StdIn.fromFile ("data/input.txt") 
    StdOut.toFile ("/tmp/output.txt")
    ...


Revised: 2023-09-12 22:12