Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming 12 Mr. Jean March 3 rd, 2014.

Similar presentations


Presentation on theme: "Computer Programming 12 Mr. Jean March 3 rd, 2014."— Presentation transcript:

1 Computer Programming 12 Mr. Jean March 3 rd, 2014

2 The plan: Video Clip of the day Why Java? Using Jcreator Learning how to create a project in Jcreator

3 2.1 Why Java? Java is the fastest growing programming language in the world. Java is a modern object-oriented programming language. Java has benefited by learning from the less desirable features of early object-oriented programming languages.

4 2.1 Why Java? Java is ideally suited to develop distributed, network-based applications because it: –Enables the construction of virus-free, tamper-free systems (security) –Supports the development of programs that do not overwrite memory (robust) –Yields programs that can be run on different types of computers without change (portable)

5 2.1 Why Java? Java supports advanced programming concepts such as threads. –A thread is a process that can run concurrently with other processes. Java resembles C++, the world’s most popular industrial strength programming language. Java however, runs more slowly than most modern programming languages because it is interpreted.

6 2.2 The Java Virtual Machine and Byte Code Java compilers translate Java into pseudomachine language called java byte code. To run java byte code on a particular computer, a Java virtual machine (JVM) must be installed.

7 2.2 The Java Virtual Machine and Byte Code A Java virtual machine is a program that acts like a computer. It is called an interpreter. Disadvantage: –Runs more slowly than an actual computer To combat slower processing, some JVMs translate code when first encountered. This is known as just-in-time compilation (JIT).

8 2.2 The Java Virtual Machine and Byte Code Advantages: –Portability. Any computer can run Java byte code. –Applets. Applets are small Java programs already translated into byte code. Applets run in a JVM incorporated in a web browser Applets can be decorative (like animated characters on a web page.) Applets can be practical (like continuous streams of stock market quotes.) –Security. It is possible to limit the capabilities of a Java program since it runs inside a virtual machine.

9 How to build new projects:

10

11

12

13

14

15

16 Today’s Goals: We will be introduced to classes and static methods and are shown how to compile and run a Java program.

17 First Program in Java This simple program causes the word “Hello” to be printed. To start: –Find jcreator on your computer –Open jcreator and copy to code from my PPT onto your jcreator

18 J-creator Video: http://www.youtube.com/watch?v=Bmryow 3NYPE (Getting Started)http://www.youtube.com/watch?v=Bmryow 3NYPE http://www.youtube.com/watch?v=SMHK3 oO8zLg (Hello World)http://www.youtube.com/watch?v=SMHK3 oO8zLg http://www.youtube.com/watch?v=3u1fu6f 8Hto (About Java & Applications)http://www.youtube.com/watch?v=3u1fu6f 8Hto

19 Compiling & Running a program A Java program must be compiled before it can be run by the Java system (Java Virtual Machine). –The complier translates the Java program into the underlying Java machine language (called Java byte codes) and creates a file containing the result. –This file (also called the class file) is used by the Java system to run (or execute) the program producing the program output.

20 When the program is run the system looks for the main method and begins with the first instruction and then the further instructions in order. Most methods contain many instructions. In Java instructions are called statements. –Statements are executed. The program above contains the single statement that causes the word (or string) Hello to be printed. –System.out.println("Hello");

21 Creating an error: One of the functions of the compiler is to detect syntax errors. Deliberately introduce small syntax errors and observe the results.

22 Common Errors: When using JavaRoom, if the name of the class containing the main method is not the same as the name of the file, the name of the class must be selected before clicking the run button.

23 About our Program: Our program consists of a class containing a main method (a method with the name main). –the name of the class is HelloTester. –the class contains a main method which must be public (otherwise it will not run) –static(because it is not part of any object) –void (because it does not return any value). In this case the method contains only one instruction (statement) which is a call to the println method in the out object in the System class.

24 Adding information: It is important to tell other programmers what you are doing In order to do this you must start with start with “/*” and end with “*/”

25


Download ppt "Computer Programming 12 Mr. Jean March 3 rd, 2014."

Similar presentations


Ads by Google