Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Introduction to JAVA Explain the concept of Java as it fits in the current development environment. Examine its basic components, how it is implemented Demo of Projects 1 GOALS... To understand why Java is so widely used To identify Java’s benefits over other languages To identify the different type of Java applications 2 There are many different programming languages that support different development ideologies. These ideologies have evolved and were limited to the hardware capabilities of the time. 3 Initially, Computer programs were written to merely automate redundant clerical tasks. 4 However , with the development of the PC and the World Wide Web the thrust of application development has been towards more active, adaptive and intelligent “systems” (data mining , web surfing, decision analysis) 5 COBOL, PASCAL, FORTRAN Mainframe applications Procedural Extremely redundant, error prone NOT portable Compiled into machine language Need to be familiar with platforms API 6 C A “nuts and bolts” language used for support systems (not user interactive) Multi platform development (mainframe, unix, mac, pc) 7 C Still extremely procedural, redundant error prone Somewhat portable (depends on conformance to ANSI standards) Lightweight 8 C Compiled into machine language Must know platform you are developing in/for Need to be familiar with platforms API 9 C++ A “nuts and bolts” language used for support systems (not user interactive) But has ability to develop GUI / event driven apps (MFC) Bulky to develop 10 C++ Many “versions” Lightweight Attempt to move from procedural to OO Does not enforce OO concepts 11 C++ Multi platform Lends to redundancy and errors Somewhat portable (depends on conformance to ANSI standards) Excellent for game development 12 C++ Compiled into machine language Must know platform you are developing in/for Need to be familiar with platforms API 13 Visual Basic, Powerbuilder Mostly PC based Easy IDE Event Driven / GUI based 14 Visual Basic, Powerbuilder Ideal for commercial application development Databases 15 Visual Basic, Powerbuilder Introduces the ideas of distributed processing Allows for development of reusable components Run Time Interpreted 16 Visual Basic, Powerbuilder Must know platform you are developing in/for Need to be familiar with platforms API 17 What is Java ?: Java is a language that: was developed by Sun Microsystems 18 What is Java ?: Java is a language that: was developed to take advantage of (or enforce) the principles of Object Oriented Development 19 What is Java ?: Java is a language that: leverages the inherent benefits of C++ utilizes C, C++ syntax 20 What is Java ?: Java is a language that: provides a standard Virtual Machine (JVM) & Java Software Development Kit (SDK) enforces Object Oriented development 21 What is Java ?: Java is a language that: lightweight (imports what is needed, like C’s includes) multi platform greatly reduces redundancy 22 What is Java ?: Java is a language that: completely portable (go from pc to unix to mac) excellent for GUI, game, internet development 23 What is Java ?: Java is a language that: compiled into Bytecodes, then runtime interprited using the JVM Excellent Documentation --JAVADOC 24 What is Java ?: Java is a language that: Open Source Do not need to know the specific platforms API 25 What is Java ?: Java is a language that: Clean and consistent API interface (actually abstracts the developer from the specific API of the platform on which the program is being developed 26 What is Java ?: Java is a language that: This is how Java apps become truly portable Universal access to documentation , tutorials, code samples 27 What is Java ?: Java is a language that: Builds Applications Builds Applets (executed via Java enabled web browsers) 28 How Java works: You need to download Java Software Development Kit (SDK or JDK) onto your PC J2SDK 1.5.6 & Java 3D includes a compiler, interpreter, applet viewer program 29 How Java works: You develop you Java program using a simple notepad text editor or using a more advanced IDE like NetBeans, Eclipse, Visual J++, Jcreator 30 How Java works: You “compile” your program into BYTECODE (close to machine language, but abstracted from any Specific machine code instructions) Still platform independent 31 How Java works: When the program is executed, the Java Virtual Machine interprets your BYTECODE BYTECODES are interpreted on a particular computer by the Java interpreter for THAT particular CPU 32 How Java works: Myapp.java source code written in some text editor (JAVA IS CaSE SenSITIvE) Myjava.class compiled, bytecode version of my program Executed at runtime via JVM 33 How Java works: Just In Time compilation One time translation from byte code to machine language The next time that code is executed, it is done from the executable 34 How Java works: This is why applets run much faster the second time they are “run” 35 Applets vs Applications: Java applications are constructed similar to C or C++ programs They require a “MAIN” system entry point (SPVM) 36 Java applications They must all consist of classes Every Java Class inherits from Java.Lang.Object 37 Java applications The name of the FILE that holds a Java class MUST BE EXACTLY the same as the name of that class (CLASSNAME matches FILENAME) This prevents having 2 runable versions of the same class in the same folder 38 Example: the following code is from the Sample project created in the Intro to OO Lecture HelloWorld.java 39 /* * HelloWorld.java * Java Application * Description: Simple system output display of “Hello World” * @ author David Farrell * @ version 1.0 OUTPUT: Hello World */ 40 public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello World”); } } 41 We will code and execute this program in the next lecture (using the NetBeans IDE) & examine the code in detail in the Java Application lecture NOTE: the name of the java file MATCHES the name of the class (the class that contains SPVM) 42 Java Applets have the same syntax as applications Have no “MAIN” entry point Execute within Java enabled web browsers 43 Java Applets Uses the Java class JApplet The name of the file MUST be identical to the name of the applets public class (less the .java extension) 44 Java Applets Applets auto Fire: Init Start Paint 45 Example: the following code is a the file named HelloWorld2.java 46 /* * HelloWorld2.java * Java Applet * Description: Simple system output display of “Hello World” * @ author David Farrell * @ version 1.0 OUTPUT: ____________ Hello World ___________ */ 47 import javax.swing.Japplet import java.awt.Graphics public class HelloWorld2 extends JApplet { public void paint(Graphics g) { g.drawLine(15, 10, 210, 10); // 15, 10 is x,y of st of ln 210, 10 x,y eol g.drawLine(15, 30, 210, 30); g.drawString(“Hello World”, 25. 25) } 48 } The HTML: <html> <applet code=”HelloWorld2.class” width=300 height=40> </applet> </html> 49 Program Demos: Craps Java Applet CoinFlip2 Java Applet DialogBoxForInput Java App (also available in this lecture’s “Code Sample” section TicTacToe Java Applet ---- RUN BY STARTING THE ASSOCIATED index.html 50 Program Demos: GO INTO C:\Program Files\Java\jdk1.5.0_06\demo\applets Select a folder and CLICK on the HTML to run the applets, Open up and view the source code 51 Other Project Options: GUI and Event Driven programs possible: Swing is like VB for creating Forms with buttons, labels and textboxes Graphics is like Open GL, SDL or CMU graphics, Especially Java 3D 52 TEST IS NEXT !!! 53