3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Size: px
Start display at page:

Download "3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)"

Transcription

1 GETTING STARTED: YOUR FIRST JAVA APPLICATION 15 3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS) GETTING STARTED: YOUR FIRST JAVA APPLICATION Checklist: The most recent version of Java SE Development Kit (JDK) can be downloaded from A text editor such as Notepad or WordPad Your first application, HelloWorld will simply display the greeting Hello world! using the command prompt. The steps are: 1. Create a source file To create your first Java source file (or called as source code): i. Start any text editor then create a new document, if necessary. ii. Type the class header public class HelloWorld. Press Enter once then type. iii. Press Enter again and then type }. We will add main()method between these curly braces. iv. As shown in Figure 3.1 below, add the main()method between the curly braces by typing public static void main (String[] args). Then type a set of curly braces for main(). public class HelloWorld public static void main(string[] args) } } Figure 3.1 The main()method for the HelloWorld class

2 16 Java Programming Workbook v. Next, add the statement System.out.println( Hello world! ) within the main() method that can produce the output, Hello World!. public class HelloWorld public static void main(string[] args) System.out.println("Hello world!"); // Display the string. } } Figure 3.2 Complete HelloWorld class vi. Save the application as HelloWorld.java. Important: Make sure the file extension is.java by appending the.java to the file name when saving the file. Now, you may exit the text editor. 2. Compile the source file After saving the application, you must compile the source code into a.class file (or called as bytecode). To compile your source code from the command line: i. Start the command prompt. ii. Change the default drive prompt to the drive and the directory where your application is stored. iii. Type javac followed by the name of the file that contains the source code. Then press Enter. For example, to compile the HelloWorld.java, you type javac HelloWorld.java then press Enter. Figure 3.3 Changing the directory of the application

3 FIRST JAVA APPLICATION USING ECLIPSE IDE 17 Important: The name must match exactly, including the use of uppercase and lowercase characters. The compiler (javac) and launcher (java) tools are case-sensitive. Now that you have a.class file, you can run the application. 3. Run the application When the compile is successful, in order to run the source code from the command line: i. Type java followed by the class name of the source code at the command line and press Enter. For example, to run the HelloWorld.java, you type java HelloWorld. ii. The output should appear on the next line as shown in Figure 3.4 below. Figure 3.4 Output of the HelloWorld application Congratulations, your program works! FIRST JAVA APPLICATION USING ECLIPSE IDE Checklist: The most recent version of Java SE Development Kit (JDK) Eclipse IDE The steps to display the greeting Hello world! using the Eclipse IDE are:

4 18 Java Programming Workbook 1. Create a Java project Before you can do anything else in Eclipse, such as creating a Java program, you need to create a Java project. To create a new Java project, follow these steps: i. Start Eclipse IDE and make sure it is in Java perspective. If you are not already in the Java perspective, in the main menu select Window, point to Open Perspective and then choose Java. ii. Click File in the main menu and then point to New, and choose Java Project. iii. Enter helloworld for the project name as shown in Figure 3.5, then click Finish. iv. The helloworld project will be shown as a folder on the Package Explorer. 2. Create a Java class Once you have created a project for it to live in, you can create your first Java program. Although doing so is not necessary, it's a good practice to organize your Java classes into packages. Here, we'll use a package named helloworld. It is a good convention to use the top package the same name as the project. To create a new Java class, follow these steps: i. Right-click on the helloworld project and point to New, and then select Class to bring up the New Java Project window. ii. Leave the Source Folder field as it is which is helloworld/src by default. Figure 3.5 Creating new Java project named HelloWorld

5 FIRST JAVA APPLICATION USING ECLIPSE IDE 19 iii. iv. In the Package field enter helloworld and enter HelloWorld in the Name field. Check the box for public static void main(string[] arg) in the Which Method Stubs Would You Like to Create? section as shown in Figure 3.6. Then, click Finish. Figure 3.6 Creating new Java class named HelloWorld v. The Java editor will automatically open showing your new class. The code that is automatically generated includes a method stub for main(). vi. Now that you have your HelloWorld class, in the main() method, add the following statement: System.out.println("Hello world!"); vii. Then save your changes. The class will automatically compile upon saving. 3. Run the application When the compile is successful, in order to run your application in Eclipse: i. Right-click on HelloWorld.java in the Package Explorer, point to Run As and select Java Application. ii. The Console view should appear at the bottom and display the "Hello, world!" output as shown in Figure 3.7.

6 20 Java Programming Workbook Figure 3.7 Output of the HelloWorld application Congratulations! You have successfully created a Hello World application. RUN JAVA APPLICATION OUTSIDE ECLIPSE IDE In previous example, we run the application in the Eclipse IDE. To run a Java application outside the Eclipse, we need to export the program as a Java ARchive (or JAR) file. To create a JAR file for the helloworld project: 1. Right-click on the helloworld project and select Export. 2. In the Export window, select Java and then select JAR file. Click Next. 3. In the JAR Export window as shown in Figure 3.8, select helloworld project as the resource to be export. Select an export destination and a name for the JAR file. For example, choose your Desktop as the destination and helloworld.jar as the JAR file name. 4. Click Finish. A JAR file will be created in your selected destination. To run the JAR file: 1. Start the command prompt. 2. Change the default drive prompt to the drive and the directory where your JAR file is stored. 3. Type the following statement and press Enter. java -classpath helloworld.jar helloworld.helloworld 4. The output should appear on the next line as shown in Figure 3.9.

7 CREATING A DIALOG BOX 21 Figure 3.8 JAR Export window Figure 3.9 Output when running the helloworld.jar CREATING A DIALOG BOX To create a Java application that produces output in a dialog box: 1. Open the Eclipse IDE, if necessary. 2. To create a new class, right-click on the helloworld package, point to New and then click Class. 3. Enter HelloDialog in the Name field then click Finish. 4. The Java editor will automatically open showing your new class. The code that is automatically generated includes a class header and an opening and closing brace for the class named HelloDialog. 5. Position the insertion point at the end of the first line that contains the package declaration then press Enter to insert a new line. 6. Type the import statement that allows you to use the JOptionPane class: import javax.swing.joptionpane;

8 22 Java Programming Workbook 7. Position the insertion point after the opening curly brace, press Enter, and then type the following: public static void main(string[] args) JOptionPane.showMessageDialog(null, Hello world! ); } 8. Save the application. The class will automatically compile upon saving. 9. Run the application. The output should appear as shown in Figure Click OK to close the dialog box. Figure 3.10 Output of the HelloDialog application ADDING COMMENTS TO A CLASS You will add comments to your HelloWorld.java application and save it as a new class named HelloWorld2. To add comments to your application and save it as a new class: 1. Open the Eclipse IDE, if necessary. 2. Double-click the HelloWorld.java in the Package Explorer to open the file in the Java Editor. 3. Position the insertion point at the top of the file that contains the package declaration then press Enter to insert a new line. 4. Press the Up arrow to go to that line, and then type the following comments at the top of the file. Press Enter after typing each line. Insert your name and today s date where indicated.

9 ADDING COMMENTS TO A CLASS 23 // Filename HelloWorld2.java // Written by <your name> // Written on <today s date> 5. Change the HelloWorld class name to HelloWorld2, press Enter and then type the following block comment: /* This class demonstrates the use of the print() and println() method to print the message Hello, world! and I am a new student.i'm ready for Java programming. */ 6. The HelloWorld2 class name will be underlined with a problem highlight line. Ignore this problem. 7. Add the following statements below the statement that prints Hello, world! as shown in Figure 3.11: System.out.print( I am a new student. ); System.out.println( I m ready for Java programming! ); 8. Click File on the main menu and click Save As. 9. In the Save As window, change the File name to HelloWorld2.java. Click OK. You will see a new class named HelloWorld2.java created in the Package Explorer. The problem highlight name is also being fixed. 10. Run the application. The output should appear as shown in Figure Figure 3.11 The HelloWorld2 class

10 24 Java Programming Workbook Figure 3.12 Output of the HelloWorld2 application Note: As you work through this book, add comments as the first three lines of every exercise that you do. The comments should contain the number of question and the class name, purpose of the source code, your name and the date created. Do it yourself 3.1 Write, compile and test a class that prints your name on the screen. Save the class as Name.java. 3.2 Write, compile and test a class that prints your full name, matric number and your address in three separate lines on the screen. Save the class as Student.java. 3.3 Write, compile and test a class that produces a series of three dialog boxes so that each displays one line of the output from Exercise 3.2 in turn. Save the class as StudentDialog.java. 3.4 Identify and fix the errors in the following code: Public class Welcome public void Main(string[] args) System.out.println( Welcome to Java ) }

11 Do it yourself Identify the output of the following code: // Ex 3.5: Hello.java // Printing a line of text with multiple statements public class Hello public static void main(string[] args) //begin execution of program System.out.print( Welcome to ); System.out.println( Java Programming! ); }// end method main }// end class Hello 3.6 Write a Java program that will prints multiple lines of text as follows: Welcome to Java Programming! CASE PROJECT Making Money Bank intends to provide a new automated teller machine (ATM) for the customers to perform basic financial transactions. Each user has only one account at the bank. ATM users should be able to view their account balance, withdraw cash and deposit funds. The company has asked you to write a Java application for the ATM. Write, compile and test a Java class that displays Making Money Bank ATM Service and Welcome! in an attractive layout on the console screen. Be certain to use appropriate comments in your class. Save the class as MakingMoneyATM.java. Example of the layout you can create: ******************************************************************** * * * Making Money Bank ATM Service * * * ******************************************************************** Welcome!

12 26 Java Programming Workbook NOTES

These two items are all you'll need to write your first application reading instructions in English.

These two items are all you'll need to write your first application reading instructions in English. IFRN Instituto Federal de Educação, Ciência e Tecnologia do RN Curso de Tecnologia em Análise e Desenvolvimento de Sistemas Disciplina: Inglês Técnico Professor: Sandro Luis de Sousa Aluno(a) Turma: Data:

More information

Lesson 04: Our First Java Program (W01D4

Lesson 04: Our First Java Program (W01D4 Lesson 04: Our First Java Program (W01D4) Balboa High School Michael Ferraro Lesson 04: Our First Java Program (W01D4 Do Now Start a terminal shell. From there, issue these commands

More information

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

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java) Goals - to learn how to compile and execute a Java program - to modify a program to enhance it Overview This activity will introduce you to the Java programming language. You will type in the Java program

More information

CS 177 Recitation. Week 1 Intro to Java

CS 177 Recitation. Week 1 Intro to Java CS 177 Recitation Week 1 Intro to Java Questions? Computers Computers can do really complex stuff. How? By manipulating data according to lists of instructions. Fundamentally, this is all that a computer

More information

Lesson 01 Introduction

Lesson 01 Introduction Lesson 01 Introduction MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Lecturer in Management & IT M.Sc. In IS (SLIIT), PGD in IS (SLIIT), BBA (Hons.) Spl. in IS (SEUSL), MCP Programs Computer

More information

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below.

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below. CS520 Setting Up the Programming Environment for Windows Suresh Kalathur 1. Java8 SDK Java8 SDK (Windows Users) For Windows users, download the Java8 SDK as shown below. The Java Development Kit (JDK)

More information

Certified Core Java Developer VS-1036

Certified Core Java Developer VS-1036 VS-1036 1. LANGUAGE FUNDAMENTALS The Java language's programming paradigm is implementation and improvement of Object Oriented Programming (OOP) concepts. The Java language has its own rules, syntax, structure

More information

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form

More information

Getting Started with Eclipse/Java

Getting Started with Eclipse/Java Getting Started with Eclipse/Java Overview The Java programming language is based on the Java Virtual Machine. This is a piece of software that Java source code is run through to produce executables. The

More information

4 WORKING WITH DATA TYPES AND OPERATIONS

4 WORKING WITH DATA TYPES AND OPERATIONS WORKING WITH NUMERIC VALUES 27 4 WORKING WITH DATA TYPES AND OPERATIONS WORKING WITH NUMERIC VALUES This application will declare and display numeric values. To declare and display an integer value in

More information

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Introduction to Java Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Program Errors Syntax Runtime Logic Procedural Decomposition Methods Flow of Control

More information

Getting Started with Java. Atul Prakash

Getting Started with Java. Atul Prakash Getting Started with Java Atul Prakash Running Programs C++, Fortran, Pascal Python, PHP, Ruby, Perl Java is compiled into device-independent code and then interpreted Source code (.java) is compiled into

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG 1 Notice Class Website http://www.cs.umb.edu/~jane/cs114/ Reading Assignment Chapter 1: Introduction to Java Programming

More information

Javac and Eclipse tutorial

Javac and Eclipse tutorial Javac and Eclipse tutorial Author: Balázs Simon, BME IIT, 2013. Contents 1 Introduction... 2 2 JRE and JDK... 2 3 Java and Javac... 2 4 Environment variables... 3 4.1 Setting the environment variables

More information

CS 201 Software Development Methods Spring Tutorial #1. Eclipse

CS 201 Software Development Methods Spring Tutorial #1. Eclipse CS 201 Software Development Methods Spring 2005 Tutorial #1 Eclipse Written by Matthew Spear and Joseph Calandrino Edited by Christopher Milner and Benjamin Taitelbaum ECLIPSE 3.0 DEVELOPING A SIMPLE PROGRAM

More information

Full file at

Full file at Chapter 2 Introduction to Java Applications Section 2.1 Introduction ( none ) Section 2.2 First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler

More information

Even though we created a folder for the workspace, we still have to let JCreator do the same. So click File, New, and then Blank Workspace.

Even though we created a folder for the workspace, we still have to let JCreator do the same. So click File, New, and then Blank Workspace. Getting Started With JCreator The first thing to do with JCreator is to create a workspace. A workspace is an area where you can store a project or a set of related projects. For me, the best way to create

More information

CompSci 125 Lecture 02

CompSci 125 Lecture 02 Assignments CompSci 125 Lecture 02 Java and Java Programming with Eclipse! Homework:! http://coen.boisestate.edu/jconrad/compsci-125-homework! hw1 due Jan 28 (MW), 29 (TuTh)! Programming:! http://coen.boisestate.edu/jconrad/cs125-programming-assignments!

More information

1. Download the JDK 6, from

1. Download the JDK 6, from 1. Install the JDK 1. Download the JDK 6, from http://java.sun.com/javase/downloads/widget/jdk6.jsp. 2. Once the file is completed downloaded, execute it and accept the license agreement. 3. Select the

More information

NetBeans IDE Java Quick Start Tutorial

NetBeans IDE Java Quick Start Tutorial NetBeans IDE Java Quick Start Tutorial Welcome to NetBeans IDE! This tutorial provides a very simple and quick introduction to the NetBeans IDE workflow by walking you through the creation of a simple

More information

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

CS 152: Data Structures with Java Hello World with the IntelliJ IDE CS 152: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Electrical and Computer Engineering building

More information

PART 1. Eclipse IDE Tutorial. 1. What is Eclipse? Eclipse Java IDE

PART 1. Eclipse IDE Tutorial. 1. What is Eclipse? Eclipse Java IDE PART 1 Eclipse IDE Tutorial Eclipse Java IDE This tutorial describes the usage of Eclipse as a Java IDE. It describes the installation of Eclipse, the creation of Java programs and tips for using Eclipse.

More information

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you

More information

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

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) armahmood786@yahoo.com alphasecure@gmail.com alphapeeler.sf.net/pubkeys/pkey.htm http://alphapeeler.sourceforge.net pk.linkedin.com/in/armahmood

More information

How to make a "hello world" program in Java with Eclipse *

How to make a hello world program in Java with Eclipse * OpenStax-CNX module: m43473 1 How to make a "hello world" program in Java with Eclipse * Hannes Hirzel Based on How to make a "hello world" program in Java. by Rodrigo Rodriguez This work is produced by

More information

CSC116: Introduction to Computing - Java

CSC116: Introduction to Computing - Java CSC116: Introduction to Computing - Java Course Information Introductions Website Syllabus Computers First Java Program Text Editor Helpful Commands Java Download Intro to CSC116 Instructors Course Instructor:

More information

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment. CPS109 Lab 1 Source: Partly from Big Java lab1, by Cay Horstmann. Objective: i. To become familiar with the Ryerson Computer Science laboratory environment. ii. To obtain your login id and to set your

More information

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with Project 1 and Java Intro Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu

More information

Code Ninjas: Introduction to Computer Science. Macomb Science Olympiad Presented by Swati Dharia

Code Ninjas: Introduction to Computer Science. Macomb Science Olympiad Presented by Swati Dharia Code Ninjas: Introduction to Computer Science Macomb Science Olympiad Presented by Swati Dharia Intro to Java Programming The three basic steps required to get a simple program running. As with any application,

More information

Just Enough Eclipse What is Eclipse(TM)? Why is it important? What is this tutorial about?

Just Enough Eclipse What is Eclipse(TM)? Why is it important? What is this tutorial about? Just Enough Eclipse What is Eclipse(TM)? Eclipse is a kind of universal tool platform that provides a feature-rich development environment. It is particularly useful for providing the developer with an

More information

IT151: Introduction to Programming (java)

IT151: Introduction to Programming (java) IT151: Introduction to Programming (java) Programming Basics Program A set of instructions that a computer uses to do something. Programming / Develop The act of creating or changing a program Programmer

More information

Summer Assignment for AP Computer Science. Room 302

Summer Assignment for AP Computer Science. Room 302 Fall 2016 Summer Assignment for AP Computer Science email: hughes.daniel@north-haven.k12.ct.us website: nhhscomputerscience.com APCS is your subsite Mr. Hughes Room 302 Prerequisites: You should have successfully

More information

CSC116: Introduction to Computing - Java

CSC116: Introduction to Computing - Java CSC116: Introduction to Computing - Java Intro to CSC116 Course Information Introductions Website Syllabus Computers First Java Program Text Editor Helpful Commands Java Download Course Instructor: Instructors

More information

Getting Started (1.8.7) 9/2/2009

Getting Started (1.8.7) 9/2/2009 2 Getting Started For the examples in this section, Microsoft Windows and Java will be used. However, much of the information applies to other operating systems and supported languages for which you have

More information

Introduction Basic elements of Java

Introduction Basic elements of Java Software and Programming I Introduction Basic elements of Java Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Module Information Time: Thursdays in the Spring term Lectures: MAL B04: 2

More information

Fundamentals of Programming. By Budditha Hettige

Fundamentals of Programming. By Budditha Hettige Fundamentals of Programming By Budditha Hettige Overview Exercises (Previous Lesson) The JAVA Programming Languages Java Virtual Machine Characteristics What is a class? JAVA Standards JAVA Keywords How

More information

Life Without NetBeans

Life Without NetBeans Life Without NetBeans Part A Writing, Compiling, and Running Java Programs Almost every computer and device has a Java Runtime Environment (JRE) installed by default. This is the software that creates

More information

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017 Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017 1 1. Please obtain a copy of Introduction to Java Programming, 11th (or 10th) Edition, Brief

More information

CSC116: Introduction to Computing - Java

CSC116: Introduction to Computing - Java CSC116: Introduction to Computing - Java Course Information Introductions Website Syllabus Schedule Computing Environment AFS (Andrew File System) Linux/Unix Commands Helpful Tricks Computers First Java

More information

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

2 Getting Started. Getting Started (v1.8.6) 3/5/2007 2 Getting Started Java will be used in the examples in this section; however, the information applies to all supported languages for which you have installed a compiler (e.g., Ada, C, C++, Java) unless

More information

Introduction to Java. Nihar Ranjan Roy. https://sites.google.com/site/niharranjanroy/

Introduction to Java. Nihar Ranjan Roy. https://sites.google.com/site/niharranjanroy/ Introduction to Java https://sites.google.com/site/niharranjanroy/ 1 The Java Programming Language According to sun Microsystems java is a 1. Simple 2. Object Oriented 3. Distributed 4. Multithreaded 5.

More information

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

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang Eclipse Tutorial For Introduction to Java Programming By Y. Daniel Liang This supplement covers the following topics: Getting Started with Eclipse Choosing a Perspective Creating a Project Creating a Java

More information

Setting up your Computer

Setting up your Computer Setting up your Computer 1 Introduction On this lab, you will be getting your computer ready to develop and run Java programs. This lab will be covering the following topics: Installing Java JDK 1.8 or

More information

Lab # 2. For today s lab:

Lab # 2. For today s lab: 1 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot 1 For today s lab: Go the course webpage Follow the links to the lab notes for Lab 2. Save all the java programs you

More information

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Lecture 04 Demonstration 1 So, we have learned about how to run Java programs

More information

Getting Started with Eclipse for Java

Getting Started with Eclipse for Java Getting Started with Eclipse for Java Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Publishing 1. Introduction 2. Downloading and Installing Eclipse 3. Importing and Exporting

More information

Chapter 1 Introduction to Java

Chapter 1 Introduction to Java Chapter 1 Introduction to Java 1 Why Java? The answer is that Java enables users to develop and deploy applications on the Internet for servers, desktop computers, and small hand-held devices. The future

More information

13 th Windsor Regional Secondary School Computer Programming Competition

13 th Windsor Regional Secondary School Computer Programming Competition SCHOOL OF COMPUTER SCIENCE 13 th Windsor Regional Secondary School Computer Programming Competition Hosted by The School of Computer Science, University of Windsor WORKSHOP I [ Overview of the Java/Eclipse

More information

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to: Get JAVA To compile programs you need the JDK (Java Development Kit). To RUN programs you need the JRE (Java Runtime Environment). This download will get BOTH of them, so that you will be able to both

More information

UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared by Harald Gjermundrod

UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared by Harald Gjermundrod Page 1 of 19 UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared By: Harald Gjermundrod Table of Contents 1 EASY INSTALLATION... 2 1.1 DOWNLOAD... 2 1.2 INSTALLING... 2 2 CUSTOMIZED INSTALLATION...

More information

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1 COMP 210: Object-Oriented Programming Lecture Notes 1 Java Program Structure and Eclipse Robert Utterback In these notes we talk about the basic structure of Java-based OOP programs and how to setup and

More information

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java Chapter 1 Introduction to Computers, Programs, and Java 1 Programs Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs. Without programs,

More information

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java Chapter 1 Introduction to Computers, Programs, and Java 1.1 What are hardware and software? 1. A computer is an electronic device that stores and processes data. A computer includes both hardware and software.

More information

Java: Comment Text. Introduction. Concepts

Java: Comment Text. Introduction. Concepts Java: Comment Text Introduction Comment text is text included in source code that is ignored by the compiler and does not cause any machine-language object code to be generated. It is written into the

More information

Lecture (01) Getting started. Dr. Ahmed ElShafee

Lecture (01) Getting started. Dr. Ahmed ElShafee Lecture (01) Getting started Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, fundamentals of Programming I, Agenda Download and Installation Java How things work NetBeans Comments Structure of the program Writing

More information

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar Upon completing the course, you will understand Create, compile, and run Java programs Primitive data types Java control flow Operator Methods

More information

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide Overview Welcome to this refresher workshop! This document will serve as a self-guided explanation to

More information

You should now start on Chapter 4. Chapter 4 introduces the following concepts

You should now start on Chapter 4. Chapter 4 introduces the following concepts Summary By this stage, you have met the following principles : the relationship between classes and objects that a class represents our understanding of something weʼre interested in, in a special and

More information

Read Me First! Start Here. Read Me First! Start Here.

Read Me First! Start Here. Read Me First! Start Here. Getting Started with for Mac OS JAVA Welcome! Hardware Software Disk Space B A S I C S Y S T E M R E Q U I R E M E N T S Classic Mac OS development PowerPC 601 or greater processor (no 68K support), 64

More information

16.410: Jump Starting With Java

16.410: Jump Starting With Java 16.410: Jump Starting With Java by Robert Effinger and Shannon Dong Introduction This jumpstart shows you the basics of getting Java started, running simple programs, and simple editing and debugging.

More information

Lec 3. Compilers, Debugging, Hello World, and Variables

Lec 3. Compilers, Debugging, Hello World, and Variables Lec 3 Compilers, Debugging, Hello World, and Variables Announcements First book reading due tonight at midnight Complete 80% of all activities to get 100% HW1 due Saturday at midnight Lab hours posted

More information

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

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics WIT COMP1000 Java Basics Java Origins Java was developed by James Gosling at Sun Microsystems in the early 1990s It was derived largely from the C++ programming language with several enhancements Java

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

SDKs - Eclipse. SENG 403, Tutorial 2

SDKs - Eclipse. SENG 403, Tutorial 2 SDKs - SENG 403, Tutorial 2 AGENDA - SDK Basics - - How to create Project - How to create a Class - Run Program - Debug Program SDK Basics Software Development Kit is a set of software development tools

More information

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

AP Computer Science Summer Assignment (updated 5/29/2018) DUE : Sept. 4, 2018 AP Computer Science 2018 2019 E-mail: taegoode@vbschools.com Summer Assignment (updated 5/29/2018) DUE : Sept. 4, 2018 This assignment is due on the first day of class. Please read the instructions carefully

More information

http://java.sun.com/docs/books/tutorial/getstarted/index.html1 Getting Started THIS chapter gives a quick introduction to the Java TM technology. First, we explain what the Java platform is and what it

More information

Exercise 1: Intro to Java & Eclipse

Exercise 1: Intro to Java & Eclipse Exercise 1: Intro to Java & Eclipse Discussion of exercise solution We do not put the exercise solution s source code online! But we show & publish the most important parts on slides There are sometimes

More information

Your password is: firstpw

Your password is: firstpw SHARE Session #9777: WebSphere and Rational Developer Hands-on-Labs Building Java application on System z with RDz Lab exercise (estimate duration) Part 1: Your first Java application on z/os (~35 min).

More information

Instructions. First, download the file

Instructions. First, download the file Instructions First, download the file http://www.cs.mcgill.ca/~cs202/2012-09/web/lectures/dan/unit0/helloworld.java from the course webpage. You can view this file in a program such as notepad (windows),

More information

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

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995 Java Introduc)on History of Java Java was originally developed by Sun Microsystems star:ng in 1991 James Gosling Patrick Naughton Chris Warth Ed Frank Mike Sheridan This language was ini:ally called Oak

More information

S8352: Java From the Very Beginning Part I - Exercises

S8352: Java From the Very Beginning Part I - Exercises S8352: Java From the Very Beginning Part I - Exercises Ex. 1 Hello World This lab uses the Eclipse development environment which provides all of the tools necessary to build, compile and run Java applications.

More information

Programming Principles 1 (CSC131) & 2 (CSC132) Software usage guide

Programming Principles 1 (CSC131) & 2 (CSC132) Software usage guide School of Sciences Department of Computer Science and Engineering Programming Principles 1 (CSC131) & 2 (CSC132) Software usage guide WHAT SOFTWARE AM I GOING TO NEED/USE?... 3 WHERE DO I FIND THE SOFTWARE?...

More information

Java with Eclipse: Setup & Getting Started

Java with Eclipse: Setup & Getting Started Java with Eclipse: Setup & Getting Started Originals of slides and source code for examples: http://courses.coreservlets.com/course-materials/java.html Also see Java 8 tutorial: http://www.coreservlets.com/java-8-tutorial/

More information

1) Log on to the computer using your PU net ID and password.

1) Log on to the computer using your PU net ID and password. CS 150 Lab Logging on: 1) Log on to the computer using your PU net ID and password. Connecting to Winter: Winter is the computer science server where all your work will be stored. Remember, after you log

More information

Computer Science AP 2017 Summer Assignment Mrs. McFarland

Computer Science AP 2017 Summer Assignment Mrs. McFarland Computer Science AP 2017 Summer Assignment Mrs. McFarland Read Chapter 1 from the book Think Java: How to Think Like a Computer Scientist by Allen B. Downey. I have included Chapter 1 in this pdf. If you

More information

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

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

More information

1. Go to the URL Click on JDK download option

1. Go to the URL   Click on JDK download option Download and installation of java 1. Go to the URL http://www.oracle.com/technetwork/java/javase/downloads/index.html Click on JDK download option 2. Select the java as per your system type (32 bit/ 64

More information

Getting Started with Eclipse for Java

Getting Started with Eclipse for Java Getting Started with Eclipse for Java Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Publishing 1. Introduction 2. Downloading and Installing Eclipse 3. Importing and Exporting

More information

Summer Assignment for the School Year

Summer Assignment for the School Year Summer Assignment for the 2018-2019 School Year Course: AP Computer Science A Instructor: Mr. Rivera Welcome to AP Computer Science A. I am looking forward to an exciting school year of teaching Computer

More information

Introduction to Classes and Objects Pearson Education, Inc. All rights reserved.

Introduction to Classes and Objects Pearson Education, Inc. All rights reserved. 1 3 Introduction to Classes and Objects 2 You will see something new. Two things. And I call them Thing One and Thing Two. Dr. Theodor Seuss Geisel Nothing can have value without being an object of utility.

More information

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151 Department of Computer Science University of Pretoria Introduction to Computer Science COS 151 Practical 1 16 February 2018 1 Plagiarism Policy The Department of Computer Science considers plagiarism as

More information

BASICS.

BASICS. BASICS http://www.flickr.com/photos/oskay/472097903/ CSCI 135 - Fundamentals of Computer Science I 2 Outline Computer Basics Programs and Languages Introduction to the Eclipse IDE Our First Program Comments

More information

Chapter 3 Intro to Java

Chapter 3 Intro to Java Chapter 3 Intro to Java Introducing Java Barrett Computer Science Designing Technology Solutions 1 2 Key Terminology - OS Operating System 3 Why Program in Java? Java is an Object Oriented Programming

More information

USING THE OOSIML/JAVA COMPILER. With the Command Window

USING THE OOSIML/JAVA COMPILER. With the Command Window USING THE OOSIML/JAVA COMPILER With the Command Window On Windows Operating System José M. Garrido Department of Computer Science December 2017 College of Computing and Software Engineering Kennesaw State

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

AP Computer Science A Summer Assignment

AP Computer Science A Summer Assignment Mr. George AP Computer Science A Summer Assignment Welcome to AP Computer Science A! I am looking forward to our class. Please complete the assignment below. It is due on the first day back to school in

More information

Workbook 1. In each practical class you will find three course instructors who have the following duties:

Workbook 1. In each practical class you will find three course instructors who have the following duties: Introduction Workbook 1 In this course you will work through a series of practical exercises which will improve your Java programming skills and teach you how to write distributed and concurrent programs

More information

The Command Shell. Fundamentals of Computer Science

The Command Shell. Fundamentals of Computer Science The Command Shell Fundamentals of Computer Science Outline Starting the Command Shell Locally Remote Host Directory Structure Moving around the directories Displaying File Contents Compiling and Running

More information

Eclipse. JVM, main method and using Eclipse. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Eclipse. JVM, main method and using Eclipse. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics Eclipse JVM, main method and using Eclipse Produced by: Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Files in Java. Java Virtual Machine. main method. Eclipse

More information

Introduction to Classes and Objects

Introduction to Classes and Objects 1 2 Introduction to Classes and Objects You will see something new. Two things. And I call them Thing One and Thing Two. Dr. Theodor Seuss Geisel Nothing can have value without being an object of utility.

More information

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

COMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE. Instructor: Prasun Dewan (FB 150, COMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE Instructor: Prasun Dewan (FB 150, dewan@unc.edu) SCOPE: BASICS AND BEYOND Basic use: CS 1 Beyond basic use: CS2 2 DOWNLOAD FROM WWW.ECLIPSE.ORG Get the

More information

What is Eclipse? A free copy can be downloaded at:

What is Eclipse? A free copy can be downloaded at: Using Eclipse What is Eclipse? The Eclipse Platform is an open source IDE (Integrated Development Environment), created by IBM for developing Java programs. Eclipse is now maintained by the Eclipse Foundation,

More information

Workbook A dialog box will appear asking for you to select your "workspace". Leave the default as is, which should be /home/crsid/workspace.

Workbook A dialog box will appear asking for you to select your workspace. Leave the default as is, which should be /home/crsid/workspace. In this workbook you will learn how to use Eclipse as a development environment for Java programs. Using Eclipse, you will then write a simple Java messaging client which will allow you to send and receive

More information

Imperative and Object Oriented Programming. Tutorial 1. Charlie Abela Department of Artificial Intelligence

Imperative and Object Oriented Programming. Tutorial 1. Charlie Abela Department of Artificial Intelligence Imperative and Object Oriented Programming Tutorial 1 Department of Artificial Intelligence charlie.abela@um.edu.mt Tutorial 1 In this tutorial you will be using the BlueJ IDE to develop java classes.

More information

Building Java Programs. Introduction to Programming and Simple Java Programs

Building Java Programs. Introduction to Programming and Simple Java Programs Building Java Programs Introduction to Programming and Simple Java Programs 1 A simple Java program public class Hello { public static void main(string[] args) { System.out.println("Hello, world!"); code

More information

C02: Overview of Software Development and Java

C02: Overview of Software Development and Java CISC 3120 C02: Overview of Software Development and Java Hui Chen Department of Computer & Information Science CUNY Brooklyn College 08/31/2017 CUNY Brooklyn College 1 Outline Recap and issues Brief introduction

More information

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors Outline Overview history and advantage how to: program, compile and execute 8 data types 3 types of errors Control statements Selection and repetition statements Classes and methods methods... 2 Oak A

More information

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation CPSC 150 Laboratory Manual A Practical Approach to Java, jedit & WebCAT Department of Physics, Computer Science & Engineering Christopher Newport University Lab 1 Introduction to Program Creation Welcome

More information

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8 Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How

More information

CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: Lab Instructions: Log in Create folder CS209

CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: Lab Instructions: Log in Create folder CS209 CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: 1. To create a project in NetBeans. 2. To create, edit, compile, and run a Java program using NetBeans. 3. To

More information