SlideShare a Scribd company logo
Compiling with Eclipse

Copyright © 2012, Oracle. All rights reserved.
Compiling with Eclipse

What Will I Learn?
Objectives
In this lesson, you will learn how to:
• Identify components of Eclipse
• Compile an application
• Test to ensure application is complete
• Write the code for GalToLit.java
• Continue coding until error free compilation and
execution is reached
• Modify the program to compute a different number of
gallons into its equivalent number of liters

Copyright © 2012, Oracle. All rights reserved.

2
Compiling with Eclipse

Why Learn It?
Purpose
Eclipse is an efficient and easy to
use a development environment for
creating Java programs. It is a well
known tool by many Java
programmers and is used in many
development environments.
Learning Eclipse in this lesson will
give you additional skills with tools
used in the Java programming
space.

Copyright © 2012, Oracle. All rights reserved.

3
Compiling with Eclipse

Eclipse Community & Requirements
Facts about Eclipse:
• Eclipse is created by an Open Source Community
• The Eclipse project is governed by the Eclipse
Foundation, a non-profit organization.
• Eclipse requires an installed Java Runtime
Environment (JRE).
• Eclipse contains its own development tools, i.e., a
Java compiler.

Copyright © 2012, Oracle. All rights reserved.

4
Compiling with Eclipse

Java JRE and Java JDK
JRE and JDK differences:
• Java Runtime Environment (JRE) contains only the
necessary functionality to start Java programs.
• Java Development Kit (JDK) contains functionality to
start Java programs as well as develop them.
• At a minimum, the Java JRE is required to run Eclipse.
To check if Java is already installed on your computer:
• Windows or Ubuntu operating systems: Enter java
-version in a command window.
• Mac operating system: Use the Software Update
option from the Apple menu.

Copyright © 2012, Oracle. All rights reserved.

5
Compiling with Eclipse

Launching Eclipse
To launch Eclipse:
1. On a computer with Windows double-click on the file
eclipse.exe. On a Linux or Mac computer double
click on the file eclipse.
2. When prompted, enter the pathname for the
workspace into which you will store your Java projects
and click the OK button.

Copyright © 2012, Oracle. All rights reserved.

6
Compiling with Eclipse

Launching Eclipse (cont.)
To launch Eclipse (cont.):
3. Eclipse will start and display the Welcome page.
4. Close the Welcome page by clicking the X next to the
Welcome tab name.
– There are valuable resources available from the
Welcome page
– You can return to the Welcome page by choosing
Welcome from the Help menu

Copyright © 2012, Oracle. All rights reserved.

7
Compiling with Eclipse

Eclipse Edit Area and Views
Eclipse provides an edit area and several views.
• An editor is where you type in your Java source code
• Views are sub-windows that provide information about
your project

Copyright © 2012, Oracle. All rights reserved.

8
Compiling with Eclipse

Eclipse Edit Area and Views (cont.)
The edit area uses tabs when more than one file is open.

Copyright © 2012, Oracle. All rights reserved.

9
Compiling with Eclipse

Eclipse Edit Area and Views (cont.)
The edit area can have multiple windows occupy the space.

Copyright © 2012, Oracle. All rights reserved.

10
Compiling with Eclipse

Eclipse Edit Area and Views (cont.)
Details on edit areas and views:
• A combination of views and editors are referred to as a
perspective.
• All projects are developed and modified in a
workspace.

Copyright © 2012, Oracle. All rights reserved.

11
Compiling with Eclipse

Steps to Creating a Program
To create a program in Eclipse:
1. Create a Project
2. Create a Package (inside the src folder of the project)
3. Create a Class (inside the package)
4. Create and run Java code

Copyright © 2012, Oracle. All rights reserved.

12
Compiling with Eclipse

Step 1: Create a Project
In Eclipse, all programs must reside inside a project for
proper compilation. You may have one or multiple
programs in one project.
To create a project:
• Choose File → New → Java
Project
• Enter a project name and
click Finish
• All project values are set to
default by clicking the Finish
button

Copyright © 2012, Oracle. All rights reserved.

13
Compiling with Eclipse

Step 1: Create a Project (cont.)
The project:
• Is created and displayed as a folder
• Displays in the Package view to the left of the edit area

Copyright © 2012, Oracle. All rights reserved.

14
Compiling with Eclipse

Step 2: Create a Package
To create a package (note: create the package in the src
folder):
1. Select the src folder in the Package view
2. Right click the src folder and choose New → Package

A package, in Java, is a mechanism for organizing Java classes into namespaces.
In Eclipse, packages are created inside projects.

Copyright © 2012, Oracle. All rights reserved.

15
Compiling with Eclipse

Step 2: Create a Package
A good convention is to name the top package the same
name as the Project using lower camel case.
Camel case is the practice of stringingCapitalizedWords
together with no spaces. Lower camel case does not
capitalize the lead word.

Copyright © 2012, Oracle. All rights reserved.

16
Compiling with Eclipse

Step 3: Create a Class
To create a class:
1. Right click on the project name to create a new class
named StudyPage in the studyTool package.
2. Select the option to create the main method.

A class, in Java, is a construct that
is used as a blueprint to create objects.
It can also be a construct in which
objects are created.

Copyright © 2012, Oracle. All rights reserved.

17
Compiling with Eclipse

Step 3: Create a Class (cont.)
Notice the following:
• The StudyPage.java class appears in the studyTool
package in the Package Explorer View.
• The StudyPage.java class is created with the main
method.

A main method, in Java, is the method inside a class that runs when the class
is compiled and ran.

Copyright © 2012, Oracle. All rights reserved.

18
Compiling with Eclipse

Step 4: Create and Run Java Code
To implement the main method and run the program:
1. Enter the following information into the main class:
public class studyPage {
public static void main(String[] args) {
System.out.println(“Enter a study term”);
}
}

2. Right click on StudyPage.java in
the package view.
3. Choose Run As → Java Application.
4. Save the class when prompted.
5. Note results display in the Console
View.

Copyright © 2012, Oracle. All rights reserved.

19
Compiling with Eclipse

Step 4: Create and Run Java Code (cont.)
Continue implementing the main class to accept a term,
prompt for a definition, accept a definition, and finally,
display the term and definition.
package studyTool;
import java.util.Scanner;
public class StudyPage {
public static void main(String[] args) {
Scanner scanterm = new Scanner(System.in);
String termvar;
System.out.println("Enter a study term");
termvar = scanterm.nextLine();
Continued on next slide...
Copyright © 2012, Oracle. All rights reserved.

20
Compiling with Eclipse

Step 4: Create and Run Java Code (cont.)
Continue implementing the main class to accept a term,
prompt for a definition, accept a definition, and finally,
display the term and definition.
Continued from previous slide...
Scanner scandef = new Scanner(System.in);
String termdef;
System.out.println("Enter a definition");
termdef = scandef.nextLine();
System.out.println(termvar+":

"+termdef);

}
}

Copyright © 2012, Oracle. All rights reserved.

21
Compiling with Eclipse

Program to Convert Gallons to Liters
What is the formula to convert gallons to liters?
• 1 US gallon is equivalent to 3.78541178 Liters
What is the math calculation to complete the conversion?
• Pseudocode would look like:
– Use Scanner to read in the number of gallons.
– Store the number of gallons in a variable.
– Multiply that variable by 3.785 (variable*3.785) and
store this new value into a second variable (Hint: use
double for the variables, not int).
– Display the output.

Now try it on your own. Create the program!

Copyright © 2012, Oracle. All rights reserved.

22
Compiling with Eclipse

Terminology
Key terms used in this lesson:
Camel case
Eclipse edit and view areas
Java class
Java package
Java main method
Open perspective
Switch workspace

Copyright © 2012, Oracle. All rights reserved.

23
Compiling with Eclipse

Summary
In this lesson, you learned how to:
• Identify components of Eclipse
• Compile an application
• Test to ensure application is complete
• Write the code for GalToLit.java
• Continue coding until error free compilation and
execution is reached
• Modify the program to compute a different number of
gallons into its equivalent number of liters

Copyright © 2012, Oracle. All rights reserved.

24
Compiling with Eclipse

Practice
The exercises for this lesson cover the following topics:
• Creating a Java program using Eclipse

Copyright © 2012, Oracle. All rights reserved.

25

More Related Content

What's hot

Assign 10 - Creating Projects using Eclipse IDE
Assign 10 -  Creating Projects using Eclipse IDE Assign 10 -  Creating Projects using Eclipse IDE
Assign 10 - Creating Projects using Eclipse IDE
Yogesh Deshpande
 
Eclipse_Building_Blocks
Eclipse_Building_BlocksEclipse_Building_Blocks
Eclipse_Building_Blocks
Rahul Shukla
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
mrecedu
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Gil Irizarry
 
Android App development I
Android App development IAndroid App development I
Android App development I
Thenraja Vettivelraj
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
Narcisa Velez
 
Mobile Worshop Lab guide
Mobile Worshop Lab guideMobile Worshop Lab guide
Mobile Worshop Lab guide
Man Chan
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copy
Deepa Rani
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
Rich Helton
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
Gil Irizarry
 
Webinar on How to use MyAppConverter
Webinar on How to use  MyAppConverterWebinar on How to use  MyAppConverter
Webinar on How to use MyAppConverter
Jaoued Ahmed
 
Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)
Miguel Pardal
 
Android Lab
Android LabAndroid Lab
Android Lab
Leo Nguyen
 

What's hot (13)

Assign 10 - Creating Projects using Eclipse IDE
Assign 10 -  Creating Projects using Eclipse IDE Assign 10 -  Creating Projects using Eclipse IDE
Assign 10 - Creating Projects using Eclipse IDE
 
Eclipse_Building_Blocks
Eclipse_Building_BlocksEclipse_Building_Blocks
Eclipse_Building_Blocks
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
 
Android App development I
Android App development IAndroid App development I
Android App development I
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
 
Mobile Worshop Lab guide
Mobile Worshop Lab guideMobile Worshop Lab guide
Mobile Worshop Lab guide
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copy
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Webinar on How to use MyAppConverter
Webinar on How to use  MyAppConverterWebinar on How to use  MyAppConverter
Webinar on How to use MyAppConverter
 
Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)
 
Android Lab
Android LabAndroid Lab
Android Lab
 

Similar to Compiling With Eclipse

JF_4_1_sg.pdf
JF_4_1_sg.pdfJF_4_1_sg.pdf
JF_4_1_sg.pdf
efranschristian
 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
Yakov Fain
 
Notepad tutorial
Notepad tutorialNotepad tutorial
Notepad tutorial
info_zybotech
 
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docxPage 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx
alfred4lewis58146
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
Rohit Thakur
 
Class 1
Class 1Class 1
Class 1
Dario Pilozo
 
Class 1
Class 1Class 1
Class 1
Dario Pilozo
 
Module Six Assignment Guidelines and Rubric.htmlOverviewMa.docx
Module Six Assignment Guidelines and Rubric.htmlOverviewMa.docxModule Six Assignment Guidelines and Rubric.htmlOverviewMa.docx
Module Six Assignment Guidelines and Rubric.htmlOverviewMa.docx
roushhsiu
 
3 more abouteclipse
3 more abouteclipse3 more abouteclipse
3 more abouteclipse
smitraSlideShare
 
Introduction to Eclipse
Introduction to Eclipse Introduction to Eclipse
Introduction to Eclipse
Arpana Awasthi
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview
Lars Vogel
 
intro-to-eclipse.pdf
intro-to-eclipse.pdfintro-to-eclipse.pdf
intro-to-eclipse.pdf
Sajeev P
 
Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2 Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2
Thecreating Experts
 
Eclipse Vs Netbeans
Eclipse Vs NetbeansEclipse Vs Netbeans
Eclipse Vs Netbeans
SiliconExpert Technologies
 
Integrating Maven with Eclipse
Integrating Maven with EclipseIntegrating Maven with Eclipse
Integrating Maven with Eclipse
Nikhil Bharati
 
Generating an Android App with Acceleo (Eclipse Summit Europe 2010)
Generating an Android App with Acceleo (Eclipse Summit Europe 2010)Generating an Android App with Acceleo (Eclipse Summit Europe 2010)
Generating an Android App with Acceleo (Eclipse Summit Europe 2010)
mikaelbarbero
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
Hitesh-Java
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
Mohamed Essam
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATION
AYESHA JAVED
 
6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作
zhang shuren
 

Similar to Compiling With Eclipse (20)

JF_4_1_sg.pdf
JF_4_1_sg.pdfJF_4_1_sg.pdf
JF_4_1_sg.pdf
 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
 
Notepad tutorial
Notepad tutorialNotepad tutorial
Notepad tutorial
 
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docxPage 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
 
Class 1
Class 1Class 1
Class 1
 
Class 1
Class 1Class 1
Class 1
 
Module Six Assignment Guidelines and Rubric.htmlOverviewMa.docx
Module Six Assignment Guidelines and Rubric.htmlOverviewMa.docxModule Six Assignment Guidelines and Rubric.htmlOverviewMa.docx
Module Six Assignment Guidelines and Rubric.htmlOverviewMa.docx
 
3 more abouteclipse
3 more abouteclipse3 more abouteclipse
3 more abouteclipse
 
Introduction to Eclipse
Introduction to Eclipse Introduction to Eclipse
Introduction to Eclipse
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview
 
intro-to-eclipse.pdf
intro-to-eclipse.pdfintro-to-eclipse.pdf
intro-to-eclipse.pdf
 
Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2 Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2
 
Eclipse Vs Netbeans
Eclipse Vs NetbeansEclipse Vs Netbeans
Eclipse Vs Netbeans
 
Integrating Maven with Eclipse
Integrating Maven with EclipseIntegrating Maven with Eclipse
Integrating Maven with Eclipse
 
Generating an Android App with Acceleo (Eclipse Summit Europe 2010)
Generating an Android App with Acceleo (Eclipse Summit Europe 2010)Generating an Android App with Acceleo (Eclipse Summit Europe 2010)
Generating an Android App with Acceleo (Eclipse Summit Europe 2010)
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATION
 
6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作
 

More from satriahelmy

Pertemuan 1
Pertemuan 1Pertemuan 1
Pertemuan 1
satriahelmy
 
Alin 1.3 1.5, 1.7
Alin 1.3 1.5, 1.7Alin 1.3 1.5, 1.7
Alin 1.3 1.5, 1.7
satriahelmy
 
Sti kelompok 1
Sti kelompok 1Sti kelompok 1
Sti kelompok 1
satriahelmy
 
Alin 2.2 2.4
Alin 2.2 2.4Alin 2.2 2.4
Alin 2.2 2.4
satriahelmy
 
Matrix (Alin 1.3 1.5, 1.7)
Matrix (Alin 1.3 1.5, 1.7)Matrix (Alin 1.3 1.5, 1.7)
Matrix (Alin 1.3 1.5, 1.7)
satriahelmy
 
Matrix (Alin 1.1 1.2)
Matrix (Alin 1.1 1.2)Matrix (Alin 1.1 1.2)
Matrix (Alin 1.1 1.2)
satriahelmy
 
merakit CPU (STI)
merakit CPU (STI)merakit CPU (STI)
merakit CPU (STI)
satriahelmy
 
Kuliah 4&5 sistem digital
Kuliah 4&5 sistem digitalKuliah 4&5 sistem digital
Kuliah 4&5 sistem digital
satriahelmy
 
Kuliah 2 sistem digital
Kuliah 2 sistem digitalKuliah 2 sistem digital
Kuliah 2 sistem digitalsatriahelmy
 
Kuliah 1 sistem digital
Kuliah 1 sistem digitalKuliah 1 sistem digital
Kuliah 1 sistem digital
satriahelmy
 

More from satriahelmy (12)

Pertemuan 1
Pertemuan 1Pertemuan 1
Pertemuan 1
 
Alin 1.3 1.5, 1.7
Alin 1.3 1.5, 1.7Alin 1.3 1.5, 1.7
Alin 1.3 1.5, 1.7
 
Sti kelompok 1
Sti kelompok 1Sti kelompok 1
Sti kelompok 1
 
Alin 3.4 3.5
Alin 3.4 3.5Alin 3.4 3.5
Alin 3.4 3.5
 
Alin 3.1 3.3
Alin 3.1 3.3Alin 3.1 3.3
Alin 3.1 3.3
 
Alin 2.2 2.4
Alin 2.2 2.4Alin 2.2 2.4
Alin 2.2 2.4
 
Matrix (Alin 1.3 1.5, 1.7)
Matrix (Alin 1.3 1.5, 1.7)Matrix (Alin 1.3 1.5, 1.7)
Matrix (Alin 1.3 1.5, 1.7)
 
Matrix (Alin 1.1 1.2)
Matrix (Alin 1.1 1.2)Matrix (Alin 1.1 1.2)
Matrix (Alin 1.1 1.2)
 
merakit CPU (STI)
merakit CPU (STI)merakit CPU (STI)
merakit CPU (STI)
 
Kuliah 4&5 sistem digital
Kuliah 4&5 sistem digitalKuliah 4&5 sistem digital
Kuliah 4&5 sistem digital
 
Kuliah 2 sistem digital
Kuliah 2 sistem digitalKuliah 2 sistem digital
Kuliah 2 sistem digital
 
Kuliah 1 sistem digital
Kuliah 1 sistem digitalKuliah 1 sistem digital
Kuliah 1 sistem digital
 

Recently uploaded

How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 

Recently uploaded (20)

How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 

Compiling With Eclipse

  • 1. Compiling with Eclipse Copyright © 2012, Oracle. All rights reserved.
  • 2. Compiling with Eclipse What Will I Learn? Objectives In this lesson, you will learn how to: • Identify components of Eclipse • Compile an application • Test to ensure application is complete • Write the code for GalToLit.java • Continue coding until error free compilation and execution is reached • Modify the program to compute a different number of gallons into its equivalent number of liters Copyright © 2012, Oracle. All rights reserved. 2
  • 3. Compiling with Eclipse Why Learn It? Purpose Eclipse is an efficient and easy to use a development environment for creating Java programs. It is a well known tool by many Java programmers and is used in many development environments. Learning Eclipse in this lesson will give you additional skills with tools used in the Java programming space. Copyright © 2012, Oracle. All rights reserved. 3
  • 4. Compiling with Eclipse Eclipse Community & Requirements Facts about Eclipse: • Eclipse is created by an Open Source Community • The Eclipse project is governed by the Eclipse Foundation, a non-profit organization. • Eclipse requires an installed Java Runtime Environment (JRE). • Eclipse contains its own development tools, i.e., a Java compiler. Copyright © 2012, Oracle. All rights reserved. 4
  • 5. Compiling with Eclipse Java JRE and Java JDK JRE and JDK differences: • Java Runtime Environment (JRE) contains only the necessary functionality to start Java programs. • Java Development Kit (JDK) contains functionality to start Java programs as well as develop them. • At a minimum, the Java JRE is required to run Eclipse. To check if Java is already installed on your computer: • Windows or Ubuntu operating systems: Enter java -version in a command window. • Mac operating system: Use the Software Update option from the Apple menu. Copyright © 2012, Oracle. All rights reserved. 5
  • 6. Compiling with Eclipse Launching Eclipse To launch Eclipse: 1. On a computer with Windows double-click on the file eclipse.exe. On a Linux or Mac computer double click on the file eclipse. 2. When prompted, enter the pathname for the workspace into which you will store your Java projects and click the OK button. Copyright © 2012, Oracle. All rights reserved. 6
  • 7. Compiling with Eclipse Launching Eclipse (cont.) To launch Eclipse (cont.): 3. Eclipse will start and display the Welcome page. 4. Close the Welcome page by clicking the X next to the Welcome tab name. – There are valuable resources available from the Welcome page – You can return to the Welcome page by choosing Welcome from the Help menu Copyright © 2012, Oracle. All rights reserved. 7
  • 8. Compiling with Eclipse Eclipse Edit Area and Views Eclipse provides an edit area and several views. • An editor is where you type in your Java source code • Views are sub-windows that provide information about your project Copyright © 2012, Oracle. All rights reserved. 8
  • 9. Compiling with Eclipse Eclipse Edit Area and Views (cont.) The edit area uses tabs when more than one file is open. Copyright © 2012, Oracle. All rights reserved. 9
  • 10. Compiling with Eclipse Eclipse Edit Area and Views (cont.) The edit area can have multiple windows occupy the space. Copyright © 2012, Oracle. All rights reserved. 10
  • 11. Compiling with Eclipse Eclipse Edit Area and Views (cont.) Details on edit areas and views: • A combination of views and editors are referred to as a perspective. • All projects are developed and modified in a workspace. Copyright © 2012, Oracle. All rights reserved. 11
  • 12. Compiling with Eclipse Steps to Creating a Program To create a program in Eclipse: 1. Create a Project 2. Create a Package (inside the src folder of the project) 3. Create a Class (inside the package) 4. Create and run Java code Copyright © 2012, Oracle. All rights reserved. 12
  • 13. Compiling with Eclipse Step 1: Create a Project In Eclipse, all programs must reside inside a project for proper compilation. You may have one or multiple programs in one project. To create a project: • Choose File → New → Java Project • Enter a project name and click Finish • All project values are set to default by clicking the Finish button Copyright © 2012, Oracle. All rights reserved. 13
  • 14. Compiling with Eclipse Step 1: Create a Project (cont.) The project: • Is created and displayed as a folder • Displays in the Package view to the left of the edit area Copyright © 2012, Oracle. All rights reserved. 14
  • 15. Compiling with Eclipse Step 2: Create a Package To create a package (note: create the package in the src folder): 1. Select the src folder in the Package view 2. Right click the src folder and choose New → Package A package, in Java, is a mechanism for organizing Java classes into namespaces. In Eclipse, packages are created inside projects. Copyright © 2012, Oracle. All rights reserved. 15
  • 16. Compiling with Eclipse Step 2: Create a Package A good convention is to name the top package the same name as the Project using lower camel case. Camel case is the practice of stringingCapitalizedWords together with no spaces. Lower camel case does not capitalize the lead word. Copyright © 2012, Oracle. All rights reserved. 16
  • 17. Compiling with Eclipse Step 3: Create a Class To create a class: 1. Right click on the project name to create a new class named StudyPage in the studyTool package. 2. Select the option to create the main method. A class, in Java, is a construct that is used as a blueprint to create objects. It can also be a construct in which objects are created. Copyright © 2012, Oracle. All rights reserved. 17
  • 18. Compiling with Eclipse Step 3: Create a Class (cont.) Notice the following: • The StudyPage.java class appears in the studyTool package in the Package Explorer View. • The StudyPage.java class is created with the main method. A main method, in Java, is the method inside a class that runs when the class is compiled and ran. Copyright © 2012, Oracle. All rights reserved. 18
  • 19. Compiling with Eclipse Step 4: Create and Run Java Code To implement the main method and run the program: 1. Enter the following information into the main class: public class studyPage { public static void main(String[] args) { System.out.println(“Enter a study term”); } } 2. Right click on StudyPage.java in the package view. 3. Choose Run As → Java Application. 4. Save the class when prompted. 5. Note results display in the Console View. Copyright © 2012, Oracle. All rights reserved. 19
  • 20. Compiling with Eclipse Step 4: Create and Run Java Code (cont.) Continue implementing the main class to accept a term, prompt for a definition, accept a definition, and finally, display the term and definition. package studyTool; import java.util.Scanner; public class StudyPage { public static void main(String[] args) { Scanner scanterm = new Scanner(System.in); String termvar; System.out.println("Enter a study term"); termvar = scanterm.nextLine(); Continued on next slide... Copyright © 2012, Oracle. All rights reserved. 20
  • 21. Compiling with Eclipse Step 4: Create and Run Java Code (cont.) Continue implementing the main class to accept a term, prompt for a definition, accept a definition, and finally, display the term and definition. Continued from previous slide... Scanner scandef = new Scanner(System.in); String termdef; System.out.println("Enter a definition"); termdef = scandef.nextLine(); System.out.println(termvar+": "+termdef); } } Copyright © 2012, Oracle. All rights reserved. 21
  • 22. Compiling with Eclipse Program to Convert Gallons to Liters What is the formula to convert gallons to liters? • 1 US gallon is equivalent to 3.78541178 Liters What is the math calculation to complete the conversion? • Pseudocode would look like: – Use Scanner to read in the number of gallons. – Store the number of gallons in a variable. – Multiply that variable by 3.785 (variable*3.785) and store this new value into a second variable (Hint: use double for the variables, not int). – Display the output. Now try it on your own. Create the program! Copyright © 2012, Oracle. All rights reserved. 22
  • 23. Compiling with Eclipse Terminology Key terms used in this lesson: Camel case Eclipse edit and view areas Java class Java package Java main method Open perspective Switch workspace Copyright © 2012, Oracle. All rights reserved. 23
  • 24. Compiling with Eclipse Summary In this lesson, you learned how to: • Identify components of Eclipse • Compile an application • Test to ensure application is complete • Write the code for GalToLit.java • Continue coding until error free compilation and execution is reached • Modify the program to compute a different number of gallons into its equivalent number of liters Copyright © 2012, Oracle. All rights reserved. 24
  • 25. Compiling with Eclipse Practice The exercises for this lesson cover the following topics: • Creating a Java program using Eclipse Copyright © 2012, Oracle. All rights reserved. 25