Lab 1 Instructor: Jolanta Soltis.

Slides:



Advertisements
Similar presentations
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
Advertisements

Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Object Orientated Programming
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Introduction to Java Programming, 4E
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Introduction to Java ISYS 350. A Brief History Sun Microsystems released this language in 1996 – Versions: 1.0 – 1.6 Java Development Kit, JDK – Standard.
Introduction to Java A lab course by Dr. Junaid Ahmed Zubairi SUNY Fredonia.
Using Java without BlueJ
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
PHY281Introduction to JavaSlide 1 Introduction to Java In this section we will learn how how to use Java and write our first Java Applet:  The Java Development.
SET UP COMPUTER ** PLEASE BE AWARE SCREENSHOTS MAY NOT MATCH **
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
Marlene Galea.  The JDK (Java Development Kit)  An IDE (Integrated Development Environment) ◦ Different IDEs include:  JCreator  NetBeans  BlueJ.
Introduction to Java Presented by Daniel Rosenthal Friday, November 16 th, 2007.
JSP and Servlets Lecture notes by Theodoros Anagnostopoulos.
Lesson 4 Computer Software
Parts of a Computer Why Use Binary Numbers? Source Code - Assembly - Machine Code.
Installing the SAFARIODBC.EXE For use with Excel May 3, 2002.
Programming Fundamentals 2: Background/ F II Objectives – –give a non-technical overview of Java Semester 2, Background.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Introduction to Android. Android as a system, is a java based operating system that runs on the Linux kernel. The system is very lightweight and full.
CSE 1340 Class 3. Class 03 objectives State the difference between Machine Language vs. High Level Languages Discuss some characteristics of the Java.
UCSC All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
POS 406 Java Technology And Beginning Java Code
Introduction to Java Programming with Forte Y. Daniel Liang.
( ) 1 ISYE 7210—Fall 2005 Design of Real-Time Interactive Simulations (in Java) Initial Notes Christine M. Mitchell Director & Professor Center for.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Session 1 Introduction to Java. Objectives Java Simplified / Session 1 / 2 of 32 Explain the history of Java Explain Java in brief List the types of Java.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
CS Software Studio Java Lab 1 Meng-Ting Wang PLLAB, Computer Science Department, National Tsing-Hua University.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Liferay Installation Prepared by: Do Xuan Hai 8 August 2011.
Tool Install How to download & install Java 6 & Eclipse updated version based on Dr. G. L. Ray’s slides.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Java Programming, Second Edition Appendix A Working with Java SDK 1.4.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Eclipse Project. Installing Visit to download a copy for your home computerhttp:// –Get Release version 3.0 (or.
Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
การเขียนโปรแกรมภาษา จาวา Java Programming อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 1.
Active-HDL Server Farm Course 11. All materials updated on: September 30, 2004 Outline 1.Introduction 2.Advantages 3.Requirements 4.Installation 5.Architecture.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Introduction to Java Programming, 4E Y. Daniel Liang.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Day 1 Session 2. Setup & Installation
Java programming lecture one
Introduction to Java Dept. Business Computing University of Winnipeg
Chapter 1 Introduction to Computers, Programs, and Java
Introduction to Algorithm Design
Chapter 1 Introduction to Computers, Programs, and Java
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Review of Previous Lesson
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Lab 1 Instructor: Jolanta Soltis

Check where java is installed: C:\ProgramFiles\Java\jdk1.6.0_03\bin Save your files on AFS server. Use SSH to connect or H: drive in the lab. Before you can develop an application written in the Java programming language, you will need the Java Platform Standard Edition (Java SE) development kit. It has the necessary Java Virtual Machine1 (JVM), core Application Programming Interfaces (API)s, and the compiler you'll need for most and perhaps all of your development. Note: Mac users should go to Apple's Mac OS X Java Runtime Environment. Download the JDK Download java JDK 6 Update 6: http://java.sun.com Check where java is installed: C:\ProgramFiles\Java\jdk1.6.0_03\bin J2SE 5.0 documentation: http://java.sun.com/j2se/1.5.0/download.jsp The Java Tutorial: http://java.sun.com/docs/books/tutorial

Java SE: This kit is necessary for developing all applications, except those designed for consumer devices. Java SE comes bundled with the compiler, a runtime environment, and core API. Java Platform Enterprise Edition (Java EE): This packages includes an application server, web server, J2EE APIs, support for Enterprise JavaBeans, Java Servlets API, and JavaServer Pages (JSP) technology. Use J2EE with the Java SE. Java Platform Micro Edition (Java ME): If you are interested in developing programs for Palm Pilots, screen phones, and other consumer devices, this kit provides tools for compiling, deployment and device configuration, and APIs that are specialized for each type of device. JavaFX Script Technology is a highly productive scripting language that enables content developers to create rich media and content for deployment on Java environments.

The development kits include the APIs necessary to whatever type of applications you develop in the Java programming language. Java APIs are libraries of compiled code let you add ready-made and customizable functionality to your programs to save coding time. Java programs are executed within a program called the JVM. Rather than running directly on the native operating system, the program is interpreted by the JVM for the native operating system. This is key to making your programs portable from one platform to another. In other words, you can develop your programs on a Solaris, Linux, Macintosh, or Windows, then run it on another server or platform.

Once you have the development kits you need, you are ready to begin writing code in the Java programming language. Programs are written in three basic flavors: applets, applications, and servlets/JSP pages. Applets run in the JVM built into a web browser; applications run in the JVM installed on a computer system; and servlets/JSP run in the JVM installed on a web server.

Each release of the Java 2 SDK, Standard Edition contains: Java Compiler Java Virtual Machine* Java Class Libraries Java AppletViewer Java Debugger and other tools Documentation (in a separate download bundle) 1-6

Find the directory where it was installed C:\Program Files\Java\jdk1.6.0_03\bin 1-7

PATH Do you get the following error message? Exception in thread "main" java.lang.NoSuchMethodError: main The Java runtime system needs to know where to find programs that you want to run and libraries that are needed. It knows where the predefined Java packages are, but if you are using additional packages, you must tell specify where they are located. PATH tells Java where to search for programs 1-8

Setting PATH on Windows XP The PATH variable can be set on Windows XP with the following steps. Click the Start button in the lower left of the screen. Select Control Panel from the pop-up menu. Choose System from the submenu. Click the Advanced tab. Click the Environment Variables button near the bottom and you will see two lists of variables. Look in the System variables list for a variable named PATH. If you find it, click Edit. If you don't find it, click New and enter PATH in the Variable name field. 1-9

1-10

Compiling a Java program in DOS Create the source program with a text editor (eg, DOS, Eclipse, jEdit, TextPad, ...). DOS: Open a DOS command window and cd to the directory containing the source file. Compile the source program (Greeting.java in this example) with the following DOS command: javac Greeting.java This produces one or more ".class" files, which are the object (Java byte code) form of Java programs. You can produce a ".exe" file from this, but that isn't normally done. Run it with: java Greeting This loads the Greeting.class file and all necessary classes. 1-11

Programs to use to compile java applications: TextPad Minimum Requirements: IBM Compatible PC Microsoft Windows 95 (SP#1), NT 4 (SP#6), or later versions of Windows. COMCTL32.DLL 4.70 or later (can be downloaded from http://support.microsoft.com/default.aspx?scid=KB;en-us;q186176). 3.5MB free disk space 1. From the Configure menu, choose Preferences. 2. Select the Tools page on the Preferences dialog box. 3. Click Add. 4. Select "Java SDK Commands" from the drop down menu. 5. Click OK. The Java SDK commands are automatically added to the Tools menu, if the Java SDK is installed before TextPad is first run on a PC. 1-12

Programs to use to compile java applications: Eclipse Link to download Eclipse http://www.eclipse.org/ Tutorial: http://web.njit.edu/~soltis/cis114.htm

Exercise 1 What is the problem with the following code fragment: num = 50; while (num >= 0) { System.out.println (num); Num – num + 1; }

Answer 1: This is an infinite loop. The loop will never terminate because the condition will always be true. © 2004 Pearson Addison-Wesley. All rights reserved

Exercise 2: Using a for loop, write a program that displays that squares of all integers greater than 0 and less than or equal to a given number n. © 2004 Pearson Addison-Wesley. All rights reserved

Answer 2: public class ex3 { public static void main (String[] args) int n = 5; int square = 1; for (int i = 1; i <=n; i++) square = i * i; System.out.println(square); } © 2004 Pearson Addison-Wesley. All rights reserved

Exercise 3: Which of the following is a legal Java identifier? 1ForAll oneForAll one/4/all 1_4_all 1forall © 2004 Pearson Addison-Wesley. All rights reserved

Answer 3: b. Explanation: Java identifiers cannot start with a number (so the answers in a, d and e are illegal) and cannot include the “/” character, so the answer in c is illegal. © 2004 Pearson Addison-Wesley. All rights reserved

Exercise 4: Show the output that would occur from the following code, including proper spacing. for (j = 0; j < 5; j++) { for (k = 0; k < 5; k++) if (j!=k) System.out.print(' '); else System.out.print('*'); System.out.println( ); }  

Answer: * © 2004 Pearson Addison-Wesley. All rights reserved

Explanation: The outer loop iterates from 0 to 4, and for each iteration, the inner loop also iterates from 0 to 4. For iteration of the inner loop, if j and k are not the same, a blank is output, otherwise an *. So, if j = 0 and k = 2, then two blanks are output before an *, followed by two more blanks. At the end of each iteration of the inner loop, the cursor is returned to start a new line.