Eng. Mohammed Alokshiya

Similar documents
Eng. Mohammed S. Abdualal

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar

Loops. Eng. Mohammed Abdualal. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

Methods. Eng. Mohammed Abdualal

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000)

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

Arrays. Eng. Mohammed Abdualal

Reading Input from Text File

Using Eclipse for Java. Using Eclipse for Java 1 / 1

Chapter 1 Introduction to Java

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop

Introduction to Java. Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.

II. Compiling and launching from Command-Line, IDE A simple JAVA program

Introduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Chapter 1 Introduction to Computers, Programs, and Java

For live Java EE training, please see training courses at

CHAPTER 1. Introduction to JAVA Programming

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Chapter 1 Introduction to Computers, Programs, and Java

Setup and Getting Startedt Customized Java EE Training:

LAB 1: FAMILIARITY WITH NETBEANS IDE ENVIRONMENT

Eng. Mohammed S. Abdualal

Supplement H.1: JBuilder X Tutorial. For Introduction to Java Programming, 5E By Y. Daniel Liang

Supplement II.B(1): JBuilder X Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Object Oriented Programming (II)

Lecture 1: Introduction to Java

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Module 1: Introduction to Computers, Programs, and Java

Objectives. Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer?

Chapter 1 Introduction to Computers, Programs, and Java

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

How to Install (then Test) the NetBeans Bundle

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Chapter 1 Introduction to Computers, Programs, and Java

Java Programming Language Mr.Rungrote Phonkam

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

History Introduction to Java Characteristics of Java Data types

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

In this Tutorial we present tips and trick for the development enviroment eclipse and the extension MyEclipse.

Getting Started (1.8.7) 9/2/2009

Java with Eclipse: Setup & Getting Started

NetBeans Tutorial. For Introduction to Java Programming By Y. Daniel Liang. This tutorial applies to NetBeans 6, 7, or a higher version.

Lecture (01) Getting started. Dr. Ahmed ElShafee

More Sophisticated Behaviour

Chapter 1 Introduction to Computers, Programs, and Java

3. Hello World! for IDEA. Java. Summer 2008 Instructor: Dr. Masoud Yaghini

Sun ONE Integrated Development Environment

Chapter 1: Introduction to Computers, Programs, and Java

Getting Started With Java

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Standard Edition (SE) application development Enterprise Edition (EE) enterprise development Micro Edition (ME) Internet of Things (IoT) development

ActiveSpaces Transactions. Quick Start Guide. Software Release Published May 25, 2015

Standard Edition (SE) application development Enterprise Edition (EE) enterprise development Micro Edition (ME) Internet of Things (IoT) development

This lecture will take you through simple and practical approach while learning Java Programming language.

Part I: Fundamentals of Programming

Introduction to OOP Using Java Pearson Education, Inc. All rights reserved.

1. Go to the URL Click on JDK download option

ECE 161 WEEK 4 Introduction to Programing in Java

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

Section 2.2 Your First Program in Java: Printing a Line of Text

RTMS - Software Setup

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Object Oriented Programming with JAVA

Object Oriented Programming. Java-Lecture 1

NetBeans IDE Java Quick Start Tutorial

AP Computer Science Summer Assignment (updated 5/29/2018) DUE : Sept. 4, 2018

Setting up your Computer

Introduction to JAVA Programming Language

STAR OFFICE WRITER. Lesson 1

C Sc 227 Project 1: Three Main Methods

Anatomy of a Java Program: Comments

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

JDK-WildFly-NetBeans Setup Local

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

Eclipse Environment Setup

Using Eclipse Europa - A Tutorial

Programming with Java

COMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE. Instructor: Prasun Dewan (FB 150,

CHAPTER 1 INTRODUCTION TO COMPUTERS, PROGRAMS, AND JAVA. Objectives

Object Oriented Programming

Javadocing in Netbeans (rev )

3. NetBeans IDE 6.0. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

Using APIs. Chapter 3. Outline Fields Overall Layout. Java By Abstraction Chapter 3. Field Summary static double PI

Lesson 10: Quiz #1 and Getting User Input (W03D2)

Computer Programming, I. Laboratory Manual. Experiment #6. Loops

Chapter 5 Lab Methods

C++ Spring Break Packet 11 The Java Programming Language

Transcription:

Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) Lab 1 Introduction to Java Eng. Mohammed Alokshiya September 28, 2014

Java Programming Language Java was developed by a team led by James Gosling at Sun Microsystems. Sun Microsystems was purchased by Oracle in 2010. Originally called Oak, Java was designed in 1991 for use in embedded chips in consumer electronic appliances. In 1995, renamed Java, it was redesigned for developing Web applications. Java is a full-fledged and powerful language that can be used in many ways. It comes in three editions: Java Standard Edition (Java SE) to develop client-side applications. The applications can run standalone or as applets running from a Web browser. Java Enterprise Edition (Java EE) to develop server-side applications, such as Java servlets, JavaServer Pages (JSP), and JavaServer Faces (JSF). Java Micro Edition (Java ME) to develop applications for mobile devices, such as cell phones. Java SE is the foundation upon which all other Java technology is based. There are many versions of Java SE. The latest is Java SE 8, which we will use in this Lab. Oracle releases each version with a Java Development Toolkit (JDK). For Java SE 8, the Java Development Toolkit is called JDK 1.8 (also known as Java 8 or JDK 8). You can view and download the latest version of Java at http://www.oracle.com/technetwork/java/javase/downloads/jdk 8-downloads-2133151.html. 2

Installing Java Installing java is a straightforward process. You just have to run the installation wizard and follow it (next >> next >> next... etc.). Finally, you will see a screen like this: Which tell you that you installed Java SE successfully. Congrats If you want to know which version of Java you installed, then open the Command Line and issue the following command: javac version Check the version of Installed Java If you installed the latest version, the result should be javac 1.8.0_20 3

Developing Java Programs using Netbeans NetBeans is an integrated development environment (IDE) for developing primarily with Java. It is free, open-source and easy to learn. You can download the latest version of it form to official website: https://netbeans.org/downloads/. After downloading and installing the latest version, run it from start menu: 4

Now you are ready to create your first Java program using Netbeans, but first, you need to create a project. A project is like a folder to hold Java programs and all supporting files. You need to create a project only once. Here are the steps to create a Java project: 1. From File menu, New Project to display the New Project dialog box, or simply press New Project icon from File toolbar. 2. A New Project dialog box will open. Select Java in the Categories section and Java Application in the Projects section and click Next to display the New Java Application. 5

6

3. In the Project Name field, you should type a name that gives an idea of what the project is really doing. I will rename it FirstLab since this is the first project for you. 4. Click Finish to create the project. 7

Comments Comments in Java are an integral part of any program. They help the person reading the code (often you) better understand the 8

intent and functionality of the program. There are three types of comments in Java: Line comments (beginning with //) are used for commenting on steps inside a method. Block comments (beginning with /* and end with */) are used for comments with multi lines. Javadoc comments (begin with /** and end with */) are used for commenting on an entire class or an entire method. Comments (colored by Gray color in Netbeans) are ignored while compiling the code and do not be included in compiling process, so we can easily remove them from our small projects. Now we are going to write and execute our first program, which prints Welcome Message on the Console: Welcome.java package welcome; public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); } } Copy the code and paste it in the Edit pane in Netbeans, then try to run the file: right-click in the Edit pane to display a context menu and choose Run File, or simply press (Shift + F6). 9

Now lets make some modifications to the code, to print the Welcome message in a Dialog Box: Welcome.java package welcome; import javax.swing.joptionpane; public class Welcome { public static void main(string[] args) { JOptionPane.showMessageDialog(null, "Welcome to Java!"); } } The result of executing the previous code will be a dialog box like this: 10

Reading input from user There are many ways for getting input from the user, the simplest one is using Scanner class. The next program asks the user to enter a number (radius of a circle) and the program calculates the area of the circle and print the result to the console: CalcArea.java package calcarea; import java.util.scanner; public class CalcArea { public static void main(string[] args) { // A scanner that reads input from the console Scanner input = new Scanner(System.in); System.out.println("Please enter the radius: "); // read a number int radius = input.nextint(); // calculate the area double area = 3.14 * radius * radius; } } // print the result to the Console System.out.println("Area is: " + area); Output pane after executing the program: 11

Netbeans Tips & Tricks In this section, we will cover some tips that we may encourage while using Netbeans to write Java programs; these tips help us to use Netbeans more efficiently and make our work easier and more attractive. This section will be repeated in the future labs but with new tips & tricks for each lab. sout + TAB Use this shortcut for Writing System.out.println( ); statement quickly. Write: sout, then press TAB button and see the result: CTRL + / This shortcut toggles comments around the selected lines: CTRL + Space Use this shortcut for autocompleting the statements. 12

Auto formatting Right click on Edit pane and select Format, or simply press (ALT + SHIFT + F) 13