Week 01

advertisement
CS 2511
Fall 2014

Windows:

Start->Specialized Academic Software>Programming Languages->NetBeans->NetBeans
IDE x.y.z
 where x.y.z is a version number

Linux:

Applications->Programming->NetBeans IDE x.y
 Where x.y is a version number


Make sure you have Java Platform already
installed
Netbeans Home Page:



http://www.netbeans.org
Click on “Download Free” or go to
http://netbeans.org/downloads/index.html
Download one of the following:

Java SE
 Will work fine for this class but choose one of the others if
you’re continuing on
Java EE
 All


Run the installation file downloaded

File->New Project…

Select “Java” under
Category



Note: Categories will
differ depending on
the version
downloaded
Select “Java
Application” under
Project
Click “Next >”





Enter a Project Name
Select a Project
Location
Check “Create Main
Class”
Check “Set as Main
Project”
Click “Finish”


Select the file you
want to edit in the
Project Explorer on
the left
Edit the file in the
editing area on the
right




File->New File…
Select “Java” under
Category
Select “Java Class” (or
“Java Package”)
under File Type
Click “Next >”



Enter a Class (or
Package) Name
Select the Package
desired (only when
adding a class)
Click “Finish”

Click the hammer to
build the main project



(Builds project with a
bold header if
multiple projects are
open)
Click the Green
Arrow to run the
project
Output should be at
the bottom of the
screen






Right Click on the
class you want to
create a JUnit test for
in the Project Explorer
Expand “Tools”
Click on “Create JUnit
Tests”
Select “JUnit 4.x”
Click “Select”
Click “OK”


Change expResult to
expected return value
Delete “fail("The test
case is a prototype.");”



Run->Test File
Check Results at the
bottom
Expand the results for
more details

Click to the left of a
line number to add a
break point


A red square
indicating a
breakpoint will
appear
Click on the icon at
top with line
numbers, a break
point, and a green
arrow on it



Current line is in
green
Information about
variables is located at
bottom
Use the controls at the
top to navigate
through the execution

Controls (Left to Right)

Finish Debugging Session
 Immediately stop the execution and end the program

Pause
 If program is running, stops it where it is and returns it
to debugging mode

Continue
 Run until the next breakpoint (or end of program)

Step Over
 Step over a method call and start debugging at the next
line

Step Over Expression
 Similar to Step Over except involving expressions
instead of methods

Step Into
 Continue debugging inside the selected method call

Step Out
 Continue debugging after the current method call is
finished
Download