مدرس : مهدی عمادی برنامه نویسی پیشرفته. مقدمه Java یک زبان برنامه نویسی مستقل از سکوی اجرا است در سال 1991 توسط شرکت Sun Microsystems پیشنهاد شد C یک.

Slides:



Advertisements
Similar presentations
Welcome to Java Programming. Why do I want to take this course? I want to major in EE/CSE. ECE122 is a requirement. Java is hot in Job market. It is useful.
Advertisements

Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Introduction to Java The objectives of this chapter are: To describe the key aspects of Java To describe the Java software development kit (SDK) To explain.
Object Orientated Programming
Introduction to Java Kiyeol Ryu Java Programming Language.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Java is Web-Enabled? Myth: Java is only for the Web – Java “applets” run in Web pages – Java “applications” run stand-alone.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Introduction to 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.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Getting Started What is Java? A programming language –Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure,
1 CSC 551: Web Programming Spring 2004 Java Overview  Design goals & features  platform independence, portable, secure, simple, object-oriented, … 
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
Introduction to Java Programming. Contents 1. Java, etc. 2. Java's Advantages 3. Java's Disadvantages 4. Types of Java Code 5. Java Bytecodes 6. Steps.
Introduction to Java INE2720 Web Application Software Development Essential Materials.
CSC 111 Java Programming I. Java Programming: From Problem Analysis to Program Design, Second Edition  Instructor – Salwa Hamad Al-Jasser  Office.
Introduction to Java Programming CS 21a: Introduction to Computing I First Semester,
CS413: Java Programming language Applications Applets
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
 Java Programming Environment  Creating Simple Java Application  Lexical Issues  Java Class Library.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Fundamentals of Java.  Explain the structure of a Java class  List and explain steps to write a Java program  Identify the benefits of NetBeans IDE.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Introduction to Programming Languages. Problem Solving in Programming.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
UCSC All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
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
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Clement Allen, PhD Florida A&M University SUMMER 2006.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
An Introduction to Software Development Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Creating a Java Application and Applet
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Lecture 1b- Introduction
Session #, Speaker Name Introduction to Java 5/11/2018.
Introduction to.
Introduction to Java Dept. Business Computing University of Winnipeg
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Introduction CSC 111.
Road to Object Oriented Programming
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:

مدرس : مهدی عمادی برنامه نویسی پیشرفته

مقدمه Java یک زبان برنامه نویسی مستقل از سکوی اجرا است در سال 1991 توسط شرکت Sun Microsystems پیشنهاد شد C یک زبان برنامه نویسی با امکانات مناسب برای دسترسی به سطوح پایین سیستمها و مدیریت مستقیم سخت افزار Java زبانی مناسب برای برنامه های بزرگ و پیچیده به خصوص تحت شبکه و اینترنت

کتاب برنامه نویسی JAVA how to program, Seventh Edition, Deitel & Deitel, 2007 Code Complete, Second Edition, Steve McConnell, Microsoft Press, 2004.

استفاده به عنوان :  کلاینت برنامه های وب (Applet) 5 درصد  برنامه عادی (Desktop Application) 45 درصد  سرور (servlets/JSP/EJB) 50 درصد

Java is Cross-Platform? برنامه java در یک کامپیوتر با داشتن یک کامپایلر تولید می شود بایت کد تولید شده یک فایل است که با انتقال به هر سخت افزار و هر سیستم عاملی که ماشین مجازی جاوا را دارد اجرا خواهد بود Java Source Code Java Bytecode Compiler ( javac ) Java Bytecode Execution JIT Compiler or Interpreter Compile Time زمان کامپایل Run Time زمان اجرا

Instructions in Assembly and Machine Language

High-Level Assembly-Machine Code

Evolution of Programming Languages High-level languages make programming easier Closer to spoken languages Examples  Basic  FORTRAN  COBOL  C/C++  Java

Object-Oriented Programming برنامه نویسی شی گرا یک ایده کامل برای پیاده سازی برنامه های کامپیوتری است جاوا یک زبان کامل برای ایده برنامه نویسی شی گرا می باشد

Java is Simple? Truth: Java greatly simplifies several language features  Java has automatic memory management  Does Windows and takes out the garbage  No dangling pointers. No memory leaks.  A problem for real-time programs  Java simplifies pointer handling  No explicit reference/dereference operations  Everything is a pointer (like Lisp)  No makefiles  No header files  C++ syntax streamlined

Java is Powerful? Myth: Java will increase programmer productivity for all applications by XXX%. Myth: Java will kill C++ Myth: All software should be written in Java  Unix utilities: C  Small/medium Windows-only programs: Visual Basic  String parsing: Perl  High-performance, single-platform OO systems: C++  Air traffic control, aircraft flight software: Ada  Knowledge-based systems: Lisp/CLOS/Prolog

Basic Hello World Application “Application” is Java lingo for a stand-alone Java program  Note that the class name and the filename must match  A file can contain multiple classes, but only one can be declared public, and that one’s name must match the filename File HelloWorld.java: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world."); }

Basic Hello World Application (Continued) Compiling: javac HelloWorld.java Running: java HelloWorld Output: Hello, world.

Command Line Arguments File ShowArgs.java: public class ShowArgs { public static void main(String[] args) { for(int i=0; i<args.length; i++) { System.out.println("Arg " + i + " is " + args[i]); }

Command Line Arguments, Results Compiling and Running: > javac ShowArgs.java > java ShowArgs fee fie foe fum Arg 0 is fee Arg 1 is fie Arg 2 is foe Arg 3 is fum

Basic Hello WWW Applet File HelloWWW.java: import java.applet.Applet; import java.awt.*; public class HelloWWW extends Applet { public void init() { setBackground(Color.gray); setForeground(Color.white); setFont(new Font("SansSerif", Font.BOLD, 30)); } public void paint(Graphics g) { g.drawString("Hello, World Wide Web.", 5, 35); //5=left, 35=bottom }

Basic Hello WWW Applet (Continued) File HelloWWW.html: HelloWWW: Simple Applet Test. HelloWWW: Simple Applet Test. Error! You must use a Java enabled browser.

Basic Hello WWW Applet (Continued) Compiling: javac HelloWWW.java Running: Load HelloWWW.html in a Java-enabled browser

Customizing Applets with PARAM import java.applet.Applet; import java.awt.*; public class Message extends Applet { private int fontSize; private String message; public void init() { setBackground(Color.black); setForeground(Color.white); fontSize = getSize().height - 10; setFont(new Font("SansSerif", Font.BOLD, fontSize)); // Read heading message from PARAM entry in HTML. message = getParameter("MESSAGE"); } public void paint(Graphics g) { if (message != null) g.drawString(message, 5, fontSize+5); }

Customizing Applets with PARAM, cont. The Message Applet The Message Applet Sorry, these examples require Java Sorry, these examples require Java...

Customizing Applets with PARAM, Result

Requirements for the Course Browse-to-download: Java SE JDK 6 latest update for Windows Platform make sure to Accept License Agreementhttp://java.sun.com/ Install JDK (use defaults) Browse-to-and-download: NetBeans IDE 6.5 IDE with Java SE update ? Bundle make sure to Accept License Agreementhttp:// install NetBeans (use defaults) IntelliJ IDEA 6.0 Eclipse - IBM Rational Developer - Jdeveloper - Jbuilder - etc. NOTEPAD !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Evolution of Programming Languages Compiler: a program that translates a program written in a high-level language into the equivalent machine language  In the case of Java, this machine language is the bytecode Java Virtual Machine (JVM): hypothetical computer developed to make Java programs machine independent

Problem-Analysis-Coding-Execution Cycle

First Cup of Java A Step by step example on how to  Create  Compile  Run a java program  Plus the works What is a Programming Language What is Object Orientation

First Java Program Does and Don'ts Java Environment A Simple Program that Displays Hello World  Create the Program  Compile the Program  Load and Run the Program

First Java Program The Do not(s) Do Not Use the Desktop or “My Documents” as a folder for your java programs Always Use the Letter Drive as your Root (A, C, D, etc.) Java Does not Like Spaces in File Names or Folder Names Java is case Sensitive  the string hello.Java is not the same as Hello.java

First Java Program Start a DOS Commands window Start  Run  cmd

First Java Program Command Prompt Window

First Java Program Create the Appropriate folders

Which Java Environment are you running javac is not recoginzed: it is not in my path

Search your drive for the latest JDK Hardwire the path to point to the bin folder

Hardwire the path to point to the bin folder

java and javac are both recognizable

Where is my First Java Program Remember: java is case sensetive

Where is my First Java Program edit and save to the Homeworks folder

Where is my First Java Program Use the dir command: 228 Bytes

My First Java Program Comments Java is case sensitive File name extension is.java (Lower case) Class Name in public class HelloWorld Should exactly match the first part of the filename HelloWorld.java A runnable Java Program is a Java class with a method called: public static void main(String[] args){ //Control Flow Code }

Compiling My First Java Program javac Helloworld.java Helloworld.class is created

Compiling My First Java Program Where did HelloWorld.class come from

Running My First Java Program java Helloworld

Try this HelloWorld.java program Create, compile and run // // My First Java Program //our Info // import javax.swing.*; public class HelloWorld{ public static void main(String[] args){ try{ String s = JOptionPane.showInputDialog("Please Enter your Name"); System.out.println("Hello " + s); System.out.print(" Welcome to CIS at WTAMU"); } catch(Exception e){ }

Summary

My J2SE Environment Install Environment

Java 2 Standard Edition Components