Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Part I : Chapter 01 Introduction to Java Programming.

Similar presentations


Presentation on theme: "1 Part I : Chapter 01 Introduction to Java Programming."— Presentation transcript:

1 1 Part I : Chapter 01 Introduction to Java Programming

2 2 Objectives To learn about Java and its history. To create, compile, and run Java programs. To understand the Java runtime environment. To write a simple Java application.

3 3 History of Java Green Project Developed by a team led by James Gosling at Sun Microsystems. 1991: Oak (use in embedded consumer electronic application) 1995: Java (redesigned for developing Internet applications) James Gosling and Duke http://java.sun.com/people/jag/

4 4 History of Java This is a snapshot taken at a barbecue that James Gosling threw for some of the folks associated with the Green Team. From left to right they are: Al Frazier, Joe Palrang, Mike Sheridan, Ed Frank, Don Jackson, Faye Baxter, Patrick Naughton, Chris Warth, James Gosling, Bob Weisblatt, David Lavallee, and Jon Payne. Missing in action: Cindy Long, Chuck Clanton, Sheueling Chang, and Craig Forrest. ( http://java.sun.com/features/1998/05/birthday.html)

5 5 Java Version History VersionCode-NameRelease Date JDK 1.1.4SparklerSept 12, 1997 JDK 1.1.5PumpkinDec 3, 1997 JDK 1.1.6AbigailApril 24, 1998 JDK 1.1.7BrutusSept 28, 1998 JDK 1.1.8ChelseaApril 8, 1999 J2SE 1.2PlaygroundDec 4, 1998 J2SE 1.2.1(none)March 30, 1999 J2SE 1.2.2CricketJuly 8, 1999 J2SE 1.3KestrelMay 8, 2000 J2SE 1.3.1LadybirdMay 17, 2001 J2SE 1.4.0MerlinFeb 13, 2002 J2SE 1.4.1HopperSept 16, 2002 J2SE 1.4.2MantisJune 26, 2003 J2SE 5.0 (1.5.0)TigerSept 29, 2004 Java SE 6.0 (1.6.0)MustangDecember 11, 2006 Java SE 6 Update 14 - May 28, 2009 Java SE 7.0 (1.7.0)DolphinPlan to release in 2010

6 6 Characteristics of Java Java is simple. Java is Object-Oriented Java is Case-sensitive Java is Interpreted (Write-Once, Run-Anywhere) Java is Robust Java is Multithreaded Java can be manipulated in two ways: Application and Applet

7 7 Platform of Java Technologies Java, Micro Edition (JME TM technology) Java, Standard Edition (JSE TM technology) Java, Enterprise Edition (JEE TM technology)

8 8 Platform of Java Technologies http://java.sun.com/java2/whatis/index.html

9 9 Architecture of Java Java Programming Language Java class file Java Virtual Machine (Java VM) Java API Computer System Java platform API = Application Programming Interface

10 10 Typical Java Development Environment Java source code Java compiler (javac) HTML page Java Interpreter (java) Appletviewer or Browser Application Applet.java.class.html

11 11 Typical Java Development Environment Disk Primary Memory JVMEditorCompilerClass LoaderBytecode Verifier

12 12 Style of Java Programming Java application –Run in text mode –Run in GUI mode Java applet <applet code=“myApplet.class” width=… height=…>

13 13 Anatomy of the Application Program Comments Reserved Words Modifiers Statements Blocks Classes Methods The main method

14 14 Java Keywords abstractboolean break bytecase catchchar class constcontinue defaultdo double elseextend falsefinal finally floatfor gotoif implementation importinstanceof int interface long nativenew null package private protectedpublic return short static superswitch synchronized this throwthows transienttrue try voidvolatile while

15 15 The First Java Application Example // A first program in Java public class Welcome { public static void main ( String args[] ) { System.out.println(“Welcome to Java Programming”); } Begin class definition Declaration of main methodArguments of main method

16 16 The First Java Application Example System.out is a standard output object to display text in text mode println is a method of System.out To call a method, use. between a class / object’s name and the method –System.out.println(“…”); –car.getLevel();

17 17 The First Java Application Example Save as a name of Welcome.java compile Welcome.java –javac Welcome.java –See the output run –java Welcome –See the output

18 18 Java Application Example II // Printing multiple lines in a dialog box import javax.swing.JOptionPane; public class Welcome2 { public static void main (String args[] ) { JOptionPane.showMessageDialog ( null, “Welcome\nto\nJava\nProgramming!”); System.exit(0); // terminate the program }

19 19 Java Application Example II import javax.swing.JOptionPane; to call a class named JOptionPane into the class. JOptionPane.showMessageDialog ( null, “Welcome\nto\nJava\nProgramming!”); call a method named showMessageDialog of JOptionPane class. System.exit(0); is applied as the last command of the class to return resource to the system.

20 20 Java Application Example II Save the file as Welcome2.java compile Welcome2.java –javac Welcome2.java –See the output run –java Welcome2 –See the output

21 21 The First Applet // The first applet in Java import javax.swing.JApplet; import java.awt.Graphics; public class WelcomeApplet extends JApplet { public void paint ( Graphics g ) { g.drawString( “Welcome to Java Programming”, 25, 25 ); } inheritance

22 22 The First Applet Save the file as WelcomeApplet.java compile WelcomeApplet.java –javac WelcomeApplet.java –See the result run –Create a html file to call the applet –Save the.html file. Name the file in any name such as welcome.html –run by typing appletviewer welcome.html –Or call the.html in any browser program.

23 23 End of Chapter01 Introduction to Java


Download ppt "1 Part I : Chapter 01 Introduction to Java Programming."

Similar presentations


Ads by Google