Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic.

Similar presentations


Presentation on theme: "1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic."— Presentation transcript:

1 1 1 1 Introduction to Java

2 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic content – Now also used to: Develop large-scale enterprise applications Enhance WWW server functionality Provide applications for consumer devices (cell phones, etc.)

3 3 Java Class Libraries Classes – Include methods that perform tasks Return information after task completion – Used to build Java programs Java provides class libraries – Known as Java APIs (Application Programming Interfaces)

4 4 FORTRAN, COBOL, Pascal and Ada FORTRAN – FORmula TRANslator COBOL – COmmon Business Oriented Language Pascal – Structured programming Ada – Multitasking

5 5 BASIC, Visual Basic, Visual C++, C# and.NET BASIC – Beginner’s All-Purpose Symbolic Instruction Code.NET –.NET platform Visual Basic.NET – Based on BASIC Visual C++ – Based on C++ C# – Based on C++ and Java

6 6 Typical Java Development Environment Java programs normally undergo five phases – Edit Programmer writes program (and stores program on disk) – Compile Compiler creates bytecodes from program – Load Class loader stores bytecodes in memory – Verify Bytecode Verifier confirms bytecodes do not violate security restrictions – Execute JVM translates bytecodes into machine language

7 7 Fig. 1.1 Typical Java development environment.

8 8 Creating a Program with JCreator Click on the JCreator Icon IDE window appears

9 9 Creating a Program with JCreator Click on File, New, then Project Project Wizard appears – Choose Java Application template

10 10 Creating a Program with JCreator Give the project a name Then click Next

11 11 Creating a Program with JCreator You will want the JDK version 1.5 This tab is where you can specify hsa library At this point you can click on Finish

12 12 Creating a Program with JCreator Now we create our class (the program) with File, New, and Class The Class Wizard appears. Specify a name for the class and make sure Public is chosen For now, you can proceed with Finish

13 13 Creating a Program with JCreator The wizard creates a template. Now complete the program with the required commands.

14 14 Creating a Program with JCreator Run the compiler with Build, and CompileFile Build Output shows in bottom pane. This is where compiler error messages will be displayed.

15 15 Creating a Program with JCreator To run the compiled program click on Build, and ExecuteFile Program runs in separate window Without Creating a Project

16 16 Programming with "Ready to Program" Find the "Ready" option on the program menu or click on the "Ready" icon

17 17 Programming with "Ready to Program" An empty editor window appears

18 18 Java Programs A Java program consists of one or more classes The name of the file and the name of the class must, that is MUST have the same name Classes consist of a collection of Data items Methods Classes consist of a collection of Data items Methods A Java class with a method called main() is a Java application.

19 19 Creating a Java Application The "Ready" environment will give you skeleton or boilerplate format for programs Click on File, New, and HSA Console option A dialog box asks for the name of the class

20 20 Creating a Java Application The appropriate boilerplate text appears in the edit window – note the color coding Bold Face Java keywords Black Identifiers in Java Class library Blue Identifiers in your program Green Comments Red Quoted Strings

21 21 Creating a Java Application Fill in the necessary commands Save the program Note that a dialog box will ask you for the name Be sure to give it exactly the same name as the class Note that a dialog box will ask you for the name Be sure to give it exactly the same name as the class

22 22 Creating a Java Application To run a Java program – Press the Run button or – Press Ctrl+R or – Press F1 The console program shows a console window

23 23 Creating a Java Application Make sure to save the program before quitting – The "Ready" environment will remind you To exit the "Ready" environment – Click the X close or – Choose File, Exit or – Use Ctrl-Q

24 24 Creating a Java Application Errors in the program – Syntax errors are found for you by the compiler Dialog box shows how many errors Error line(s) highlighted Description of error given in the status bar

25 25 Why Different IDEs? Which one you use depends on what you are doing – In class the Ready to Program IDE is easy to use, “quick and dirty” – But … it does not support JDK 5.0 JCreator – supports JDK 5.0 Eclipse – a bit more complicated, but does a bit more – found to be a bit balky with some elements of JDK 5.0


Download ppt "1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic."

Similar presentations


Ads by Google