Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.

Similar presentations


Presentation on theme: "Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate."— Presentation transcript:

1 Lecture 2: Do you speak Java?

2 From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate current problem (Analysis) –Transform this model to logical models (Design) –Transform this model to software (implementation) Need to translate model to something computers can understand (mathematical equations)

3 Parlez Vous Binary? 1001110000010101010000001111 How do we translate our business problem into machine code? Initially, a programmer writes a program in a particular programming language. This is called source code!!!!! To execute the program however, the programmer must translate it into machine language……the language that the computer understands. How do we do this? –A COMPILER does this!!!!!

4 Compiler A compiler converts source code into machine level instructions Almost every programming language comes with a compiler In effect, the compiler is the language because it defines which instructions are acceptable

5 Javac The Java compiler (javac) is the component of the Java Developers kit (JDK) USED TO TRANSFORM Java source code files into bytecode (not machine code) Bytecode is the compiled format for Java programs. Once a Java program has been converted to bytecode, it can be transferred across a network and executed by the Java Virtual Machine

6 Java Virtual Machine Bytecode is not really machine code and cannot be used by a computer – it must be interpreted The Java Virtual Machine (JVM) is an interpreter, it interprets byte code and can thus execute quickly The Java interpreter is built into Java compatible web browsers such as Internet Explorer

7 Why Compile and Interpret? Because byte code is used instead of machine code, a java program can be executed on any machine that has a Java interpreter This makes java extremely portable……a program can be compiled on one machine and executed on any Java used extensively on web sites Java not only offers portability but identical behaviour on different systems “WRITE ONCE, RUN EVERYWHERE”

8 Compiling and interpreting Java source code is written with a text editor and saved in plain ASCII text with file extension.java These files are compiled using the javac compiler –E.g. javac Examplehelloworld.java Executable bytecode class files have the extension.class and they represent a Java class in its usable form The Java compiler generates exactly one.class file for each class you create. It is possible to define more than one class in a single source file, it is therefore possible for the compiler to generate multiple class files from a single source file.


Download ppt "Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate."

Similar presentations


Ads by Google