Contents [0/6] |
(Click here for one slide per page)
The most common problem with eclipse [1/6] |
If eclipse has lots of errors like these:
Then delete the file module-info.java
.
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:
To fix it, pull up eclipse preferences. On windows, this is under
the window
menu.
Navigate to the compiler
pane so that you can see the
compliance level.
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.
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:
Try
"Project" > "Clean..." > "Clean all projects"
If that does not work, try deleting potentially problematic files to re-create a fresh eclipse-workspace:
Exit eclipse
Using the finder or terminal, remove the following files/directories:
eclipse-workspace/.metadata
eclipse-workspace/algs4/.classpath
eclipse-workspace/algs4/.project
If you are using finder on a mac, you may need to make these files visible. To do this, press "Command-Shift-. (period)"
Restart eclipse. You should have a blank eclipse-workspace.
Follow the previous instructions to show the
algs4
project, by following the previous instructions
to install the code from class, starting with File > New >
Java Project
What to do if you cannot see package explorer in Eclipse [4/6] |
To show the package explorer, do this:
Once it is showing, you can adjust the view using the buttons:
No files? Run problems? [5/6] |
You may see that the algs4
project is empty, like this:
You may get this Run As
box in eclipse, like this:
Or this:
This means that the algs4 project is not initialized properly. Here are some steps:
delete algs4 in eclipse follow the instructions again to re-create it
If still not working, check that eclipse is running in the
correct place. You can see where it is running by doing
File > Switch Workspace
. That will show you
what directory/folder you are currently running in. Make sure
that this is where you unzipped the material for the class. If
not, switch, and try again.
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:
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