Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Introduction to Java and Eclipse
1 / 17
Introduction to Java and Eclipse
Natalie Perna
Department of Computing and Software
McMaster University
Week 1: Sept 10 - 14
Natalie Perna
Introduction to Java and Eclipse
1 / 17
Introduction to Java and Eclipse
2 / 17
Outline
Outline
1 Getting Started
Getting Java
Integrated Development Environments (IDEs)
Setting Up Eclipse
Downloading Eclipse
“Installing” Eclipse
2 “Hello, World!”
3 Examining a Program
4 Further Reading
5 Next Week
Natalie Perna
Introduction to Java and Eclipse
2 / 17
Introduction to Java and Eclipse
3 / 17
Getting Started
Getting Java
Getting Java
1
Visit http://www.oracle.com/technetwork/java/
javase/downloads/index.html
2
Download and install the correct version of “Java Platform
(JDK) 7u7” for your system.
Natalie Perna
Introduction to Java and Eclipse
3 / 17
Introduction to Java and Eclipse
4 / 17
Getting Started
Integrated Development Environments (IDEs)
What is an IDE?
What is an IDE?
Natalie Perna
Introduction to Java and Eclipse
4 / 17
Introduction to Java and Eclipse
5 / 17
Getting Started
Integrated Development Environments (IDEs)
What is an IDE?
IDE = Integrated Development Environment
Software application
Usually includes:
source code editor
build automation tools
debugger
Natalie Perna
Introduction to Java and Eclipse
5 / 17
Introduction to Java and Eclipse
6 / 17
Getting Started
Integrated Development Environments (IDEs)
Java IDEs
Some popular Java IDEs:
1
Eclipse
2
Java Development Kit (JDK)
3
NetBeans
4
BlueJ
Natalie Perna
Introduction to Java and Eclipse
6 / 17
Introduction to Java and Eclipse
7 / 17
Getting Started
Setting Up Eclipse
Downloading Eclipse
1
Visit http://www.eclipse.org/downloads/packages/
eclipse-ide-java-developers/junor
2
Download the correct version of “Eclipse IDE for Java
Developers” for your system.
Natalie Perna
Introduction to Java and Eclipse
7 / 17
Introduction to Java and Eclipse
8 / 17
Getting Started
Setting Up Eclipse
“Installing” Eclipse on a Mac
Mac
1
Find .tar.gz file (probably in your Downloads folder)
2
Drag it to the Desktop
3
Double-click on it and find a folder named “eclipse”
4
Drag “eclipse” folder into Applications folder
5
Inside “eclipse” folder find application named “Eclipse”
6
Drag it to your dock to make it easier to launch
Natalie Perna
Introduction to Java and Eclipse
8 / 17
Introduction to Java and Eclipse
9 / 17
Getting Started
Setting Up Eclipse
“Installing” Eclipse on a Linux Machine
Ubuntu
Find and install Eclipse from the Ubuntu Software Center.
Other Distributions
Instructions should mirror Mac instructions.
Natalie Perna
Introduction to Java and Eclipse
9 / 17
Introduction to Java and Eclipse
10 / 17
Getting Started
Setting Up Eclipse
“Installing” Eclipse on a PC
Windows
1
Find .zip file (probably in your Downloads folder)
2
Right-click on it
3
Select “Extract All. . . ” and extract to “C:” (or whatever your
root drive is)
4
After it is extracted, drag “eclipse.exe” to your Start menu to
make it easier to launch
Natalie Perna
Introduction to Java and Eclipse
10 / 17
Introduction to Java and Eclipse
11 / 17
“Hello, World!”
“Hello, World!” I
1
Launch Eclipse.
2
Specify a Workspace (a directory where you would like Eclipse
to save your work) and press OK.
Create a new Java Project:
3
File → New → Java Project
Project name: “My First Project”
Click Finish
You may have to click the small “x” to leave the Welcome
screen.
Natalie Perna
Introduction to Java and Eclipse
11 / 17
Introduction to Java and Eclipse
12 / 17
“Hello, World!”
“Hello, World!” II
4
Create a new Java Class:
File → New → Class
Name: HelloWorld
Check box to create a “public static void main(String[] args)”
method
Click Finish
Natalie Perna
Introduction to Java and Eclipse
12 / 17
Introduction to Java and Eclipse
13 / 17
“Hello, World!”
“Hello, World!” III
5
Write Your Program:
Replace “// TODO Auto-generated method stub” with
“System.out.println("Hello, World!");”.
File → Save
public
c l a s s HelloWorld {
public
s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {
System . o u t . p r i n t l n ( " H e l l o , ␣ World ! " ) ;
}
}
Natalie Perna
Introduction to Java and Eclipse
13 / 17
Introduction to Java and Eclipse
14 / 17
“Hello, World!”
“Hello, World!” IV
6
Run Your Program:
Click the Run button (a round green play button) or Ctrl-F11.
The Console at the bottom of the windows should display
“Hello, World!”.
Natalie Perna
Introduction to Java and Eclipse
14 / 17
Introduction to Java and Eclipse
15 / 17
Examining a Program
Examining a Program
Source: http://introcs.cs.princeton.edu/java/11cheatsheet
Natalie Perna
Introduction to Java and Eclipse
15 / 17
Introduction to Java and Eclipse
16 / 17
Further Reading
Further Reading
Find a Java tutorial you like and go through it step-by-step.
If you’ve programmed in Java before, take an hour to refresh.
Natalie Perna
Introduction to Java and Eclipse
16 / 17
Introduction to Java and Eclipse
17 / 17
Next Week
Next Week
Topics and examples from “The Elements of Java Style”
Make sure to get a copy before next week
Natalie Perna
Introduction to Java and Eclipse
17 / 17