May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/5461 - Operating Systems Revision 1.6 February 9, 2004.

Slides:



Advertisements
Similar presentations
Date: Subject:Distributed Data Processing Name:Maria Br ü ckner.
Advertisements

The Java Language. Topics of this Course  Introduction to Java  The Java Language  Object Oriented Programming in Java  Exceptions Handling  Threads.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Introduction to Object- Oriented Programming with Java Spring Semester 2003 Paul Krause.
Introduction to Java Programming, 4E
1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Pointers and Arrays C and Data Structures Baojian Hua
Netprog 2002 Java Intro1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network.
Introduction to Java.
Introduction Who we are How we’re going to help: Java and course- related material Subsribe to mailing list: COMP 346:
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.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
JavaServer Pages Syntax Harry Richard Erwin, PhD CSE301/CIT304.
Programming Languages and Paradigms Object-Oriented Programming.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
Java and C++, The Difference An introduction Unit - 00.
DAT602 Database Application Development Lecture 5 JAVA Review.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Distributed Systems (236351) Tutorial 1 - Getting Started with Visual Studio C#.NET.
May 14, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part II COMP346/ Operating Systems Revision 1.5 July 23, 2003.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
Introduction to Java University of Sunderland CSE301 Harry R. Erwin, PhD.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Basic Java Syntax CSE301 University of Sunderland Harry R Erwin, PhD.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
POS 406 Java Technology And Beginning Java Code
Introduction to java Prepared By:-Pragnesh Patel Lect. In Computer Dept. NSIT,Jetalpur 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
C# Versus Java Author: Eaddy, Marc Source: Software Tools for the Professional Programmer. Dr. Dobb's Journal. Feb2001, Vol. 26 Issue 2, p74 Hong Lu CS699A.
Java for C++ Programmers Clint Jeffery University of Idaho
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
We will talking about story of JAVA language. By Kristsada Songpartom.
Introduction to Java COM379 (Part-Time) University of Sunderland Harry R Erwin, PhD.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
Java -- A very Hot Object- Oriented Language Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
CSI 3125, Preliminaries, page 1 Compiling the Program.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
OOP Basics Classes & Methods (c) IDMS/SQL News
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
SOFTWARE DEVELOPMENT FOUNDATIONS, 1/12/12 J. Yates Monteith, Clemson University.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Object Oriented Programming Lecture 2: BallWorld.
Spring 2006 Special Topics in Computer Engineering: Java Intro 1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Foundations of Programming: Java
Object Oriented Programming in
Intro to ETEC Java.
Chapter No. : 1 Introduction to Java.
CompSci 230 Software Construction
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
(Computer fundamental Lab)
Java Programming Language
Presentation transcript:

May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004

May 9, 2002Serguei A. Mokhov, 2 Topics Me, Myself, and I Why Java 1.2.*? Setting Up the Environment Buzz about Java –Java vs. C++ –Basic Java Syntax –Compiling and Running Java Programs –Example(s) Next Tutorial References

May 9, 2002Serguei A. Mokhov, 3 Me, Myself, and I Name: Serguei Mokhov, for simplicity just Serguei, no “Sir”s please!!! :-) - maybe the best way to reach me. Questions are welcome (but please allow some time to reply - I’m only one and you’re so many :-) ). My Course web page for COMP346/546:

May 9, 2002Serguei A. Mokhov, 4 Setting Up the Environment Please, refer to the separate set of slides for Java version and setting up environment.

May 9, 2002Serguei A. Mokhov, 5 Why is Java sooo co0OL ??? “Dear Serguei, you promised an Intro to Java!!” Here it goes: Java is a quite simple, OO, distributed, interpreted, robust and secure, platform and architecture independent, multithreaded and dynamic language. A bunch of buzzwords? No, they aren’t buzzwords, it’s just an incomplete summary of the features of the language.

May 9, 2002Serguei A. Mokhov, 6 Java vs. C/C++ Java’s syntax is very similar to that of C/C++; thus, it is quite easy to learn for C/C++ programmers. However, there are some conceptual differences behind this syntactical similarity, which you should pay close attention to.

May 9, 2002Serguei A. Mokhov, 7 Java vs. C/C++ (2) Java –is pure OO language unlike C/C++. –has everything as an object with and exception of few primitive data types ( int, float, etc.). –uses two-byte (16 bit) Unicode characters. –has well defined and sometimes mandatory to use the Exception Handling Mechanism (will be covered later). –has automatic garbage collection.

May 9, 2002Serguei A. Mokhov, 8 Java vs. C/C++ (3) Java DOESN’T have –Multiple inheritance (well, it somewhat does through interfaces and, but this is not a true inheritance). –Templates. Vast majority of objects inherit from the Object class or its descendants (implicitly or explicitly), so any object can be cast to the Object class. –Pointers, only references. All objects manipulated by reference by default in Java, not like in C++. So, there is no & in the syntax for function parameters. –Operator overloading –Some others…

May 9, 2002Serguei A. Mokhov, 9 Java Program Structure Since Java is a pure OO language even the main() function has to be defined in a class. An instance of the class, which defines main(), will be the main thread when run. There should be only one public class with main in a file and the file name must be the same (including capitalization and spelling) as the main class’ name plus the.java extension. In general: one (any) public class per file. It is possible to have more than one class defined within one.java file, but only one of them should be public and the file name should correspond to that, public, class name. When a java program compiled with no errors with javac, a JVM object code is produced and stored in.class files. One file per class.

May 9, 2002Serguei A. Mokhov, 10 Java Program Structure (2) main() –Declaration: public static void main(String argv[]){ … } –The argv is a list of arguments passed via command line, just like in C/C++. –There is no argc in Java for a reason we’ll see in a moment. –Note, unlike in C/C++, there’s no return value that you have to explicitly pass back using the return ; statement. Use System.exit( ); instead.

May 9, 2002Serguei A. Mokhov, 11 Examples Immortal Hello World Application Note, a java file must be named as HelloWorld.java public class HelloWorld { public static void main(String argv[]) { System.out.println(“Hello dear World! It’s me again!”); } }

May 9, 2002Serguei A. Mokhov, 12 Examples (2) Command Line Arguments ShowArguments.java public class ShowArguments { public static void main(String argv[]) { for(int i = 0; i < argv.length; i++) System.out.println(“Arg[“ + i + ”]: ” + argv[i]); } } A public property of an array object Simple string concatenation with “+”

May 9, 2002Serguei A. Mokhov, 13 Compiling and Running a Java Application Command line compiler: javac javac HelloWorld.java To run the compiled code you have to invoke JVM to interpret it: java HelloWorld (Note: no extension this time, just the name of the main class!)

May 9, 2002Serguei A. Mokhov, 14 On-line Tutorial Sun’s Tutorial on Java: Material for the course: –Getting Started –Learning the Java Language –Essential Java Classes, especially Thread and Object –Collections For your own pleasure and enjoyment: –Everything else :-)

May 9, 2002Serguei A. Mokhov, 15 Next Tutorial Arrays Exception Handling Basics of Inheritance in Java Threads and Scheduling More Examples Whatever I forgot to mention above and your questions.

May 9, 2002Serguei A. Mokhov, 16 Links and References Official Java site: Java in a Nutshell, Second Edition by David Flanagan, (C) 1997 O’Reily & Associates, Inc. ISBN: X Past semester’s stuff from Paul and Tony on Dr. Aiman Hanna’s web site: Manual pages for ssh, vim, [x]emacs, pico