the eclipse platform - free university of bozen-bolzanorusso/ap/eclipseplatformslides.pdf · •...

6
02/03/15 1 THE ECLIPSE PLATFORM Compile, execute, debugging 0 5 10 15 20 25 30 1 Blanks Ques+ons Ques+ons with no answer What is the goal of compila5on? What is the java command for compiling a piece of code? What is the output of compila5on? What is the goal of execu5on? What is the java command for execu5on? Can I execute without compiling my code? What is the the main task of a Java Virtual Machine? What is just in 5me compila5on? and who does perform it? What do I do if the compiler output an error? If the compiler does not output an error, can I say that my code is bugH free? What is the goal of debugging? 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 Blanks distribu.on No. of students vs. no. blanks

Upload: others

Post on 26-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: THE ECLIPSE PLATFORM - Free University of Bozen-Bolzanorusso/AP/EclipsePlatformSlides.pdf · • ECLIPSE LUNA . 02/03/15 3 Compile, execute, debug • Create a java project • Import

02/03/15

1

THE ECLIPSE PLATFORM Compile, execute, debugging

0"

5"

10"

15"

20"

25"

30"

1"

Blan

ks'

Ques+ons'

Ques+ons'with'no'answer'

What"is"the"goal"of"compila5on?"

What"is"the"java"command"for"

compiling"a"piece"of"code?"

What"is"the"output"of"compila5on?"

What"is"the"goal"of"execu5on?"

What"is"the"java"command"for"

execu5on?"

Can"I"execute"without"compiling"my"

code?"

What"is"the"the"main"task"of"a"Java"

Virtual"Machine?"

What"is"just"in"5me"compila5on?"and"

who"does"perform"it?"

What"do"I"do"if"the"compiler"output"an"

error?"

If"the"compiler"does"not"output"an"

error,"can"I"say"that"my"code"is"bugH

free?"

What"is"the"goal"of"debugging?"

0"1"2"3"4"5"6"7"8"9"

10"

0" 1" 2" 3" 4" 5" 6" 7"

Blanks'distribu.on'

No."of"students"vs."no."blanks"

Page 2: THE ECLIPSE PLATFORM - Free University of Bozen-Bolzanorusso/AP/EclipsePlatformSlides.pdf · • ECLIPSE LUNA . 02/03/15 3 Compile, execute, debug • Create a java project • Import

02/03/15

2

Solution •  What is the goal of compilation?: The compiler translates the source code into the java bytecode

that is executed and translated into machine language by the java interpreter

•  What is the java command for compiling a piece of code?: javac java file with extension

•  What is the output of compilation?: Translate high level code into low level one (e.g., machine code)

•  What is the goal of execution?: Perform machine code operations

•  What is the java command for execution? java class file without extension

•  Can I execute without compiling my code? Yes, only is I write in machine code

•  What is the the main task of a Java Virtual Machine? An implementation of a JVM for the specific machine, translates abstract bytecode into architecture-specific machine code and executes it in the JRE

Solution •  What is just in time compilation? and who does perform it? The JVM performs JIT on the

bytecode. JIT is the process of translating bytecode into machine level instructions only when it needs to be executed.

•  What do I do if the compiler output an error? Review the code and fix any error that the compiler tells me there is.

•  If the compiler does not output an error, can I say that my code is bug-free? No, there can still be logical errors or run-time errors

•  What is the goal of debugging? To check for logical errors in the code and to check the execution of the code step-by-step. Any variable value can be inspected thanks to debugging at any point of the execution.

JSE8

•  ECLIPSE LUNA

Page 3: THE ECLIPSE PLATFORM - Free University of Bozen-Bolzanorusso/AP/EclipsePlatformSlides.pdf · • ECLIPSE LUNA . 02/03/15 3 Compile, execute, debug • Create a java project • Import

02/03/15

3

Compile, execute, debug

•  Create a java project

•  Import the file into your project

–  You can see the mistakes. Debug the class

•  Fix the mistakes and click the run button

–  Nothing happens as you forgot to enter the variables

•  Configure the execution tab (do not forget to include parameters)

•  Configure the debug tab (do not forget to include parameters)

Debugging

Javadoc

•  Comment your code between these symbols

/** … **/

Use @ tags to create the structure of the comment

Page 4: THE ECLIPSE PLATFORM - Free University of Bozen-Bolzanorusso/AP/EclipsePlatformSlides.pdf · • ECLIPSE LUNA . 02/03/15 3 Compile, execute, debug • Create a java project • Import

02/03/15

4

Commenting your code

•  There are two ways to comment your code

•  Including your comments in // or /* */

•  Using additionally the Javadoc commands together with /* */

•  If you type /* and go next line you get automatically the frame

/* * */

Commenting your code

•  If you write /** and next line before a method or a class, you also get automatically the tags about the method or the class (e.g., parameters and return type)

•  Of course you can also embed other info

•  When you generate the javadoc for that file you get an html file that describe the API of your file.

•  Before generating the javadoc you must have created a doc folder

Create your first API

•  First create a folder where to store the html files

•  Then execute “Generate Javadoc” from the Project tab

Page 5: THE ECLIPSE PLATFORM - Free University of Bozen-Bolzanorusso/AP/EclipsePlatformSlides.pdf · • ECLIPSE LUNA . 02/03/15 3 Compile, execute, debug • Create a java project • Import

02/03/15

5

Create a jar file In the Package Explorer, you can optionally pre-select one or more Java elements to export.

•  Select the project you want to export and follow the wisard.

•  In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field.

•  Select the appropriate checkbox to specify whether you want to Export generated class files and resources or Export Java source files and resources.

•  In the Select the export destination field, either type or click Browse to select a location for the JAR file.

•  Select or clear the Compress the contents of the JAR file checkbox.

•  Click Next to use the JAR Packaging Options page to set advanced options, create a JAR description, or change the default manifest.

Page 6: THE ECLIPSE PLATFORM - Free University of Bozen-Bolzanorusso/AP/EclipsePlatformSlides.pdf · • ECLIPSE LUNA . 02/03/15 3 Compile, execute, debug • Create a java project • Import

02/03/15

6

Executing jar files

•  Command line –  > java –jar file.jar

Jar and runnable jar execution