1 / 17

Java Programming Lecture 1

Java Programming Lecture 1. Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung U niversity email: cheng@cse.tt u .edu.tw http:/ / www.cse.ttu.edu.tw/~cheng. Contents (chapter 1). Short History Java Development tools

niles
Télécharger la présentation

Java Programming Lecture 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Programming Lecture 1 Instructors: Fu-Chiung Cheng (鄭福炯) Associate Professor Computer Science & Engineering Tatung University email: cheng@cse.ttu.edu.tw http:// www.cse.ttu.edu.tw/~cheng

  2. Contents (chapter 1) • Short History • Java Development tools • Install JBuilder Tool and Samples • Getting Started With Java Programming • Compiling and Running a Java Application • Compiling and Running a Java Applet

  3. History • James Gosling • Oak (Embedded consumer electronic appliances) • Java, May 20, 1995, Sun World • HotJava • The first Java-enabled Web browser

  4. JDK Versions • JDK 1.02 (1995) • JDK 1.1 (1996) • Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) • Java 2 SDK v1.3 (a.k.a JDK 1.2, 2000) • Java 2 SDK v1.4 (Dec. 2001) • Java 2 SDK v1.5 (June 2003 ??)

  5. Java Development Tools • Sun JDK • Inprise JBuilder (RAD) • Microsoft Visual J++ • Symantec Café (RAD) • Rouge Wave JFactory • Sun Java Workshop • IBM Visual Age for Java (RAD)

  6. Install JBuilder and Samples • Install JBuilder • Install Sample Programs • Setup JDK 1.2.2 environment • Set classpath=%classpath%;c:\jbbook • Set path=%path%;c:\jdk1.2.2\bin • Check Java Home: • www.javasoft.com

  7. Getting Started with Java Programming • A Simple Java Application • Compiling Programs • Executing Applications • A Simple Java Applet • Viewing Java Applets • Applications vs. Applets

  8. A Simple Application Example 1.1 //This application program prints Welcome //to Java! public class Welcome { public static void main (String[] args) { System.out.println("Welcome to Java!"); } } Source Run

  9. Compiling Programs • On command line • javac file.java

  10. Executing Applications • On command line • java classname

  11. Example javac Welcome.java java Welcome output:...

  12. A Simple Applet Example 1.2 /* This is an example of Java applets */ import java.awt.Graphics; public class WelcomeApplet extends java.applet.Applet { public void paint (Graphics g) { g.drawString("Welcome to Java!",10,10); } } Source

  13. Creating an HTML File <html> <body> <applet code="WelcomeApplet.class" width = 100 height = 40> </applet> </body> </html>

  14. Viewing Java Applets

  15. Applet Viewer Utility appletviewer htmlfile.html Example: appletviewer WelcomeApplet.html Run Applet Viewer

  16. Applications vs. Applets • Similarities • Differences

  17. Security Restrictions on Applets • Applets are not allowed to read from, or write to, the file system of the computer viewing the applets. • Applets are not allowed to run any programs on the browser’s computer. • Applets are not allowed to establish connections between the user’s computer and another computer except with the server where the applets are stored.

More Related