-
Notifications
You must be signed in to change notification settings - Fork 0
Tut00
Jim edited this page Sep 4, 2024
·
89 revisions
- This somewhat terrifying tutorial will get you ready to code Java in the (relatively) simple Eclipse IDE!
- Learning how to use your IDE is a really good time investment 🙂👍
- We will also fill in some gaps in your knowledge of computer basics
- NOTE: If you have any problems feel free to email Jim or we can fix them together on the first day of class 🙂👍
- A window is made up of panes
- A GUI (pronounced "gooey") lets you interact with a computer program using the mouse (includes checkboxes, buttons, icons, etc.)
- Most programs you use have a GUI, but some, like the Terminal/Command Prompt, do not
- A text editor lets you edit text
- A debugger helps you find bugs in your code
- A "graphical debugger" has a GUI, and is usually a lot easier to use than a pure "command-line debugger"
- An IDE is a text editor plus other stuff (debugger, etc.)
- Highlight text by clicking and dragging the mouse
- Press
⌘ + C
to copy - Press
⌘ + V
to paste - NOTE: There is also
⌘ + X
to "cut," which copies the text and deletes it
- Highlight text by clicking and dragging the mouse
- Press
CONTROL + C
to copy - Press
CONTROL + V
to paste - NOTE: There is also
CONTROL + X
to "cut," which copies the text and deletes it
- Click the trackpad with two fingers
- Open a Terminal by pressing
⌘ + SPACE
, typingterminal
, and pressingENTER
- A Terminal should pop up in the home directory (denoted by a
~
)- If not in the home directory, in the Terminal, type
cd ~
and pressENTER
to change directory to the home directory
- If not in the home directory, in the Terminal, type
- In the Terminal, type
cd Desktop
and pressENTER
- Open a Command Prompt by pressing
⊞ Win
, typecmd
, and pressingEnter
- A Command Prompt should pop up in the home directory (mine is
C:\Users\jbern
) - In the Command Prompt, type
cd Desktop
and pressENTER
It will be easier to read the course webpage in "light mode" (black text on white background).
-
Option A (easier): Set you system theme to a light mode
- 🍏 Mac: Press
⌘ + SPACE
typeAppearance
and pressEnter
; select a light theme. - 🤷♂️ Windows: Press
⊞ Win
, typeTurn on light mode systemwide
, and pressEnter
; selectLight
- 🍏 Mac: Press
-
Option B: Change theme of Github only.
- Log in to Github (make an account if you don't already have one) and click the circular icon in the top right ->
Settings
->Appearance
; setTheme mode
toSingle theme
and selectLight default
.
- Log in to Github (make an account if you don't already have one) and click the circular icon in the top right ->
🧑🔬 NOTE: If you are working on a Lab Machine, please skip to Clone the Codebase.
- Install Homebrew
- In the Terminal, type
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
and pressENTER
- Read the bottom of the message that brew prints to your Terminal.
- If there are additional instructions there, follow them as well. 🙂👍
- In the Terminal, type
- Install Git
- In the Terminal, type
brew install git
and pressENTER
- In the Terminal, type
- Download Installer
- Open the downloaded file (it can be found by clicking the ⬇️ button at the right-top corner of Edge)
- You may get a
User Account Control
popup- Press 'Yes'
- Click
Next
- Click
Next
-
Select Components
window- Uncheck all boxes
- Click
Next
- Click
Next
-
Choosing the default editor used by Git
window- Choose
Use Notepad as Git's default editor
- Choose
- Mash
Next
/Install
until it starts actually installing - Congratulations, you have installed Git
Uninstall any versions of Java already on your computer.
- Open a Terminal and run
java -version
- If you get an error (command java not found or similar): You have no Java! Please continue to the next step 🙂👍
- If a recent-ish Java version (e.g., Java 17) is installed: This is actually probably fine. Continue to the next step 🙂👍
-
If an ancient Java version (e.g., 1.8) is installed: We need to uninstall Java!
-
Windows: Press
⊞ Win
, typeadd or remove programs
, and pressEnter
; Uninstall Java -
Mac: Open a Terminal and run the following commands (you can copy them all at once by clicking the icon in the top right (⧉))
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane sudo rm -rf /Library/Application\ Support/Oracle/Java/ sudo rm -rf /Library/Java/JavaVirtualMachines
-
Windows: Press
- Download the right Eclipse 2021-12-R installer for your Mac
- Click the Apple icon at the top left of your screen ->
About This Mac
- Click the Apple icon at the top left of your screen ->
- Double-click the downloaded file (it can be found by clicking the ⬇️ button at the right-top corner of Safari)
- A Finder window should pop up
- Click and drag Eclipse (🔮) into the Applications shortcut (📁) to install Eclipse
- Click the red x (❌) to close the Finder window
- There Eclipse installer (⬜️) is still on your Desktop; eject it by right clicking its icon and pressing
Eject "Eclipse"
- Download Zip Folder
- Open the downloaded file (it can be found by clicking the ⬇️ button at the right-top corner of Edge)
- Click
Extract all
- Make sure
Show extracted files when complete
box is checked - Click
Extract
- The unzipped folder should pop up
- Click and drag the inner
eclipse
folder to yourDesktop
- Close the
File Explorer
window - Double-click the
eclipse
folder to open it - Hold the
ALT
key and drageclipse.exe
onto yourDesktop
to make a desktop shortcut - Close the
File Explorer
window
- Open a new Terminal
- Navigate to the Desktop
- Type
git clone https://github.com/james-bern/CS136.git
- Press
ENTER
⚠️ IMPORTANT: Never update Eclipse- Open Eclipse
- 🍏 Press
⌘ + SPACE
, typeeclipse
, and pressENTER
to open Eclipse - 🤷♂️ Double-click
eclipse.exe - Shortcut
to open Eclipse
- 🍏 Press
- A window titled
Eclipse IDE Launcher
should pop up - Check the box for
Use this as default and do not ask again
- Press
Launch
- A webpage may open (for...some reason)
- Close it
- Close the
Welcome
pane
- In Eclipse,
File
->Open Projects from File System...
Directory...
-
Desktop
->CS136
- Press
Open
- Press
Finish
- In
Package Explorer
on the left...- Click the
>
next toCS136
- Click the
>
next to(default package)
- Double-click
HelloCow.java
- Click the
⚠️ IMPORTANT: If Eclipse ever offers to switch its Perspective automatically, checkRemember my decision
and say NO 🙅- If you mess this (or any other stuff) up, just lemme know 🙂👍
⚠️ IMPORTANT: If Eclipse ever offers to save your file before running, checkRemember my decision
and say YES 🙆⚠️ IMPORTANT: If Eclipse wants say it needs to go around your firewall, ALLOW 🙆-
Option A: Press the
Debug
button (🪲) -
Option B: Press the keyboard shortcut for
Debug
- NOTE: You can find it in the top menu under
Run
->Debug
- NOTE: On a laptop, you may
F11
may actually beFn + F11
- NOTE: You can find it in the top menu under
- Press the keyboard shortcut (something involving
F11
) - 🥳 Amuse yourself with a rousing game of Tic Tac Toe
- Open the Preferences
- 🍏
Eclipse
->Settings...
- 🤷♂️
Window
->Preferences
- 🍏
- Disable Content Assist Auto Activation
-
Java
->Editor
->Content Assist
- NOTE: You will need to click the
>
's to drop down the menus
- NOTE: You will need to click the
- Uncheck the box for
Enable auto activation
-
- Disable Initial Folding
-
Java
->Editor
->Folding
- Make sure
Enable folding
is checked (leave it alone) - Make sure all other boxes are unchecked (you should have to uncheck two boxes)
-
- Press
Apply and Close
- Make your Eclipse looks like this (you will need to spend ~5-10 minutes with dragging the panes around):
- NOTE: If you don't already have the
Variables
andDebug
panes, you can add them with something like...- 🍏
Window
->Show View
->Variables
- 🤷♂️
Window
->Show View
-> click>
byDebug
->Variables
->Open
- 🍏
- NOTE: If you don't already have the
Console
pane, tryWindow
->Show View
->Console
- 🍏 NOTE: You may need to drag the
Problem
pane'sDescription
column separator over to the right to see anything. - NOTE: There is a
Maximize
button on the right-top (looks kinda like 💾) that will make the text editor bigger. UseRestore
(⧉) to go back.
- NOTE: If you don't already have the
- In the
Project Explorer
, right clickCS136
and pressNew
->File
- Type
HW00.java
- Press
Finish
- Open HW00 in a new window or tab (right-click on the link for options)
- Scroll down to the Starter Code
- Copy the Starter Code by pressing the button in its right-top corner (⧉)
- Paste the Starter Code into HW00.java by clicking inside of HW00.java and pressing...
- 🍏
⌘ + V
- 🤷♂️
CONTROL + V
- 🍏
Auto-Indent the Starter Code (you want usually have to do this), by clicking inside of HW00.java and pressing
- 🍏
⌘ + A
(select all) then⌘ + I
(auto indent) - 🤷♂️
CONTROL + A
thenCONTROL + I
- Run HW00 by pressing the bug (🪲) or your computer's
F11
hotkey combination that you looked up earlier
- You should get an
Errors in Workspace
popup - Press
Cancel
- Verify that you can read the compile error (missing semicolon) in the
Problems
pane like this:
- Add the missing semicolon
- Run again
- Read the runtime error (divide by zero) in the
Variables
pane like this:- NOTE: You will need to click on
main() is throwing
- NOTE: You will need to click on
- Press the
Resume
button (yellow and green icon kinda like ⏯️) to crash the program (and terminate the debugging session) - Replace
0
with6
- Run again
- Read the assert error (
2 + 2 == 5
) in theDebug
pane like this:- NOTE: You will need to click one call below the
ASSERT(...)
call in the stack trace - NOTE: A message will also be printed to the
Console
.
- NOTE: You will need to click one call below the
- Press the
Resume
button (yellow and green icon kinda like ⏯️) to crash the program (and terminate the debugging session) - Replace
5
with4
- Run again
- Read the console message (
7
) in theConsole
pane like this:
- Read the warning (
Comparing identical expressions
) in theProblems
pane like this:
- Delete the very silly
ASSERT(2 + 2 == 4);
- Run again
- 🙂👍