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

Similar documents
3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)


Certified Core Java Developer VS-1036

Chettinad College of Engineering & Technology/II-MCA/ MC9235 Web Programming WEB PROGRAMMING DEPARTMENT OF MCA

Lesson 04: Our First Java Program (W01D4

NetBeans IDE Java Quick Start Tutorial

Lecture 1: Overview of Java

Instructions. First, download the file

Life Without NetBeans

Introduction to. Android Saturday. Yanqiao ZHU Google Camp School of Software Engineering, Tongji University. In courtesy of The Java Tutorials

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

Setting up your Computer

Java: Comment Text. Introduction. Concepts

CSE 421 Course Overview and Introduction to Java

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

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

Introduction to Java

CS 177 Recitation. Week 1 Intro to Java

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

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

Getting Started with Java. Atul Prakash

CS11 Java. Fall Lecture 1

Introduction Basic elements of Java

S8352: Java From the Very Beginning Part I - Exercises

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Supplement B. Creating, Compiling and Running Java Programs from the Command Window

Chapter Two Bonus Lesson: JavaDoc

Introduction to Java. Nihar Ranjan Roy.

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

Lab # 2. For today s lab:

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

Slide 1 Java Programming 1 Lecture 2D Java Mechanics Duration: 00:01:06 Advance mode: Auto

16.410: Jump Starting With Java

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

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

Java Bytecode (binary file)

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

COMP 110 Project 1 Programming Project Warm-Up Exercise

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

Getting Started with Eclipse/Java

INF160 IS Development Environments

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

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

Fundamentals of Programming. By Budditha Hettige

Lesson 01 Introduction

Chapter 1 Introduction to Computers, Programs, and Java

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

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

Lecture (01) Getting started. Dr. Ahmed ElShafee

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

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

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

Software and Programming 1

Java Programming Constructs Java Programming 2 Lesson 1

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

Chapter 1 Introduction to Java

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

Chapter 1 Introduction to Computers, Programs, and Java

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

Chapter Goals. Chapter One: Introduction. Prerequisites. What Is Programming?

CS260 Intro to Java & Android 02.Java Technology

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

Software and Programming 1

JVM interprets the Java bytecode, controls how it interacts with the operating system and manages memory.

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

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

Anatomy of a Java Program: Comments

CSC116: Introduction to Computing - Java

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

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

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

Lab Exercise #1 Project Compilation, Javadoc Generation, and Submission Computer Science 2334

Getting Started (1.8.7) 9/2/2009

CSCI 1103: Introduction

2/9/2012. Chapter One: Introduction. Chapter Goals

Pace University. Fundamental Concepts of CS121 1

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

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

CSC116: Introduction to Computing - Java

SDKs - Eclipse. SENG 403, Tutorial 2

Building Java Programs. Introduction to Programming and Simple Java Programs

USING THE OOSIML/JAVA COMPILER. With the Command Window

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

Javac and Eclipse tutorial

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

Do this by creating on the m: drive (Accessed via start menu link Computer [The m: drive has your login id as name]) the subdirectory CI101.

Guided Tour (Version 3.3) By Steven Castellucci as Modified by Brandon Haworth

You will need to download the Java software development kit from

Introduction to Java Applications; Input/Output and Operators

GETTING STARTED. The longest journey begins with a single step. In this chapter, you will learn about: Compiling and Running a Java Program Page 2

At its simplest, a computer is a collection of wires, transistors and electrical components that are connected in a specific way When you send

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

Getting Started with Eclipse for Java

The Computer System. Hardware = Physical Computer. Software = Computer Programs. People = End Users & Programmers. people

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

Software Installation for CS121

CompSci 125 Lecture 02

Chapter 2. Editing And Compiling

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

Transcription:

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: / /. "Hello World!" for Microsoft Windows Adapted from: http://java.sun.com/docs/books/tutorial/getstarted/intro/definition.html Let s write the "Hello World!" application! The following instructions are for users of Windows XP Professional, Windows XP Home, Windows Server 2003, Windows 2000 Professional, and Windows Vista. A Checklist Creating Your First Application o Create a Source File o Compile the Source File into a.class File o Run the Program A Checklist To write this program, you'll need: 1. The Java SE Development Kit 6 (JDK 6) 2. A text editor In this example, we'll use Notepad, a simple editor included with the Windows platforms. You can easily adapt these instructions if you use a different text editor. These two items are all you'll need to write your first application reading instructions in English. Creating Your First Application Your first application, HelloWorldApp, will simply display the greeting Hello world! To create this program, you will: Create a source file A source file contains code, written in the Java programming language, that you and other programmers can understand. You can use any text editor to create and edit source files. Compile the source file into a.class file The Java programming language compiler (javac) takes your source file and translates its text into instructions that the Java virtual machine can understand. The instructions contained within this file are known as bytecodes. Run the program The Java application launcher tool (java) uses the Java virtual machine to run your application.

Create a Source File First, start your editor. You can launch the Notepad editor from the Start menu by selecting Programs > Accessories > Notepad. In a new document, type in the following code: * simply prints "Hello World!" to standard output. Public Be Careful When You Type Type all code, commands, and file names exactly as shown. Both the compiler (javac) and launcher tool (java) are case-sensitive, so you must capitalize consistently. HelloWorldApp helloworldapp Save the code in a file with the name HelloWorldApp.java. To do this in Notepad, first choose the File > Save As menu item. Then, in the Save As dialog box: 1. Using the Save in combo box, specify the folder (directory) where you'll save your file. In this example, the directory is java on the C drive. 2. In the File name text field, type "HelloWorldApp.java", including the quotation marks. 3. From the Save as type combo box, choose Text Documents (*.txt). 4. In the Encoding combo box, leave the encoding as ANSI. When you're finished, the dialog box should look like this. Now click Save, and exit Notepad. The Save As dialog just before you click Save.

Compile the Source File into a.class File Bring up a shell, or "command," window. You can do this from the Start menu by choosing Command Prompt (Windows XP), or by choosing Run... and then entering cmd. The shell window should look similar to the following figure. A shell window. The prompt shows your current directory. When you bring up the prompt, your current directory is usually your home directory for Windows XP (as shown in the preceding figure). To compile your source file, change your current directory to the directory where your file is located. For example, if your source directory is java on the C drive, type the following command at the prompt and press Enter: cd C:\java Now the prompt should change to C:\java>. Note: To change to a directory on a different drive, you must type an extra command: the name of the drive. For example, to change to the java directory on the D drive, you must enter D:, as shown in the following figure. Changing directory on an alternate drive. If you enter dir at the prompt, you should see your source file, as the following figure shows.

Directory listing showing the.java source file. Now you are ready to compile. At the prompt, type the following command and press Enter. javac _cp. HelloWorldApp.java The compiler has generated a bytecode file, HelloWorldApp.class. At the prompt, type dir to see the new file that was generated, as shown in the following figure. Directory listing, showing the generated.class file Now that you have a.class file, you can run your program. Run the Program In the same directory, enter the following command at the prompt: java _cp. HelloWorldApp The next figure shows what you should now see: The program prints "Hello World!" to the screen. Congratulations! Your program works!

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: / /. A Closer Look at the "Hello World!" Application Adapted from: http://java.sun.com/docs/books/tutorial/getstarted/intro/definition.html Now that you've seen the "Hello World!" application, you might be wondering how it works. Here again is its code: The "Hello World!" application consists of three primary components: source code comments, the HelloWorldApp class definition, and the main method. The following explanation will provide you with a basic understanding of the code. 1. Traduza o parágrafo acima:. Source Code Comments The following bold text defines the comments of the "Hello World!" application: * simply prints "Hello World!" to standard output. Comments are ignored by the compiler but are useful to other programmers. The Java programming language supports three kinds of comments: /* text The compiler ignores everything from /* to. documentation This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and. The javadoc tool uses doc comments when preparing automatically generated documentation. // text The compiler ignores everything from // to the end of the line.

The HelloWorldApp Class Definition The following bold text begins the class definition block for the "Hello World!" application: * simply displays "Hello World!" to the standard output. As shown above, the most basic form of a class definition is: class name {... The keyword class begins the class definition for a class named name, and the code for each class appears between the opening and closing curly braces marked in bold above. For now it is enough to know that every application begins with a class definition. The main Method The following bold text begins the definition of the main method: * simply displays "Hello World!" to the standard output. System.out.println("Hello World!"); //Display the string. In the Java programming language, every application must contain a main method whose signature is: public static void main(string[] args) The modifiers public and static can be written in either order (public static or static public), but the convention is to use public static as shown above. You can name the argument anything you want, but most programmers choose "args" or "argv". The main method is similar to the main function in C and C++; it's the entry point for your application and will subsequently invoke all the other methods required by your program. The main method accepts a single argument: an array of elements of type String. public static void main(string[] args) This array is the mechanism through which the runtime system passes information to your application. Each string in the array is called a command-line argument. Command-line arguments let users affect the operation of the application without recompiling it. For example, a sorting program might allow the user to specify that the data be sorted in descending order with this command-line argument: -descending

The "Hello World!" application ignores its command-line arguments, but you should be aware of the fact that such arguments do exist. Finally, the line: System.out.println ("Hello World!"); uses the System class from the core library to print the "Hello World!" message to standard output. Exercises: 1. Complete the definitions below with words taken from the text the Main Method. a) is when a program is running (or being executable). b) is a number of items arranged in some specified way. 2. Which of the following is not a valid comment: a. comment b. /* comment c. /* comment d. // comment 3. Ao declarar o método main, qual modificador deve vir primeiro, public ou static?. 4. John tried to compile the Hello World program, but he got the following error as response: HelloWorldApp2.java:7: unclosed string literal System.out.println("Hello World!); //Display the string. ^ HelloWorldApp2.java:7: ')' expected System.out.println("Hello World!); //Display the string. ^ O que causou o erro?. 5. If you want to change the HelloWorldApp.java program below so that it displays Hola Mundo!, what do you have to do?. * simply prints "Hello World!" to standard output. The main method is similar to the main function in C and C++; it's the entry point for your application and will subsequently invoke all the other methods required by your program. Traduza:.