Presentation on theme: "Computer Programming 12 Mr. Jean March 3 rd, 2014."— Presentation transcript:
Computer Programming 12 Mr. Jean March 3 rd, 2014
The plan: Video Clip of the day Why Java? Using Jcreator Learning how to create a project in Jcreator
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.
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)
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.
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.
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).
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.
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.
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");
Creating an error: One of the functions of the compiler is to detect syntax errors. Deliberately introduce small syntax errors and observe the results.
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.
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.
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 “*/”