Sie sind auf Seite 1von 33

Eclipse tutorial

Opening a new project


Select Java
project
Project name

Choose compiler
version

Separating
source from
output
Opening a class
object
In this case the
project file will be
in
~/.eclipse/Example

Class name

Inheritance
definition
Choosing Interface

Choosing functions to
add

Add javadoc Yes/No


This is
the
result
Select a method
from the menu

And the cursor


“jumps” to the
method’s position
Put the cursor on the
method’s name,
press Alt+Shift+j
and we generate
javadoc
Here we try to put an int in a
String object. On the sidebar
we have a red X and a lamp,
which means Eclipse has a
solution for us
Red X means
code with an
error

After pressing Ctrl+s we get the


list of errors in the problems tab
Eclipse offers us
completions for the
subclass methods
We can also ask Eclipse
to complete strings for
us. Write the prefix,
press alt+I,
And that is what
you get
Parameter hints: pressing
Ctrl+Alt+spacebar, gives the
possible method parameters
In case of a mistake, press
Ctrl+1 to get possible
corrections
Choose a name to
the variable, and
replace all of it’s
occurrences

If we want to make a
variable from a
constant, mark it and
press Alt+Shift+l
And that is what
you get
Choose name,
properties, and
generate javadoc

The same with methods. Mark the


relevent lines in the code, press
Alt+Shift+m
And this is what
you get
Choose extract
interface from class
Choose a name for
the interface

Choose functions
for the interface
Writing a new class

Now you need to add


getters and setters…
Choose generate getters
and setters
Choose relevent data members

Choose the rest of the properties


And this is what
you get
In order to complete a for loop, put
the cursor on the edge of the word
“for”, and press Ctrl+spacebar
Before running the
program, we need to
define the run
Choose name

Choose project

Choose the
class with the
main() method
Left click twice on a
line in the code sets
a breakpoint.

Pressing Ctrl+F11 runs the


program
In order to run in a
state where the
program stops at
breakpoints, we
press only F11

We see the run details in


the debug window
After halting, there F8: resume run until
are several options:. next breakpoint

F5 Step Into - Terminate


execute the next line
in the code. If it is a
method, execute the
first code line in the
method.
F6 Step Over –
execute the next line
in the code. If it is a
method, execute the
method.
In order to watch a variable value,
press Ctrl+alt+i

Das könnte Ihnen auch gefallen