Download presentation
Presentation is loading. Please wait.
Published byAnnis Ford Modified over 9 years ago
1
A Look at Java
2
Categorize Java Which paradigm? Which paradigm? Scripting? Scripting? Declarative or procedural? Declarative or procedural? Which generation? Which generation? Low, high, or very high level? Low, high, or very high level? Compiled or interpreted? Compiled or interpreted?
3
How Programming Works: Pre-Java 1. Programmer types a program into a text editor. This code is called the source code.This code is called the source code. It is saved as a file on your computer, much like any other file you create.It is saved as a file on your computer, much like any other file you create. Since the code is human- readable, it is usually kept private.Since the code is human- readable, it is usually kept private. #include main() { cout << "Hello World!"; return 0; }
4
How Programming Works: Pre-Java 1. Source Code 2. A program called a compiler reads the code and makes machine code instructions specific to the type of machine you are running on. This code is NOT human- readable. This code is NOT human- readable. This is what comes on software CDs, so that the code remains proprietary. This is what comes on software CDs, so that the code remains proprietary. #include main() { cout << "Hello World!"; return 0; } _main _TEXT SEGMENT _argc$ = 8 _argv$ = 12 _main PROC NEAR ; COMDAT 00000 68 00 00 00 00 push OFFSET FLAT:??_C@_0M@KPLPPDAC@Hello?5World?$AA@ 00005 e8 00 00 00 00 call _printf 0000a 83 c4 04 add esp, 4 0000d 33 c0 xor eax, eax Compiler
5
How Programming Works: Pre-Java 1. Source Code 2. Compiled to Machine Code 3. Run on the computer - Now the program can be run, but only on the machine it was compiled for. #include main() { cout << "Hello World!"; return 0; } _main _TEXT SEGMENT _argc$ = 8 _argv$ = 12 _main PROC NEAR ; COMDAT 00000 68 00 00 00 00 push OFFSET FLAT:??_C@_0M@KPLPPDAC@Hello?5World?$AA@ 00005 e8 00 00 00 00 call _printf 0000a 83 c4 04 add esp, 4 0000d 33 c0 xor eax, eax Compiler Hello World! Executed by a machine with Intel 32-bit processor
6
Java Programming Language James Gosling, Sun Microsystems, 1991 James Gosling, Sun Microsystems, 1991 Idea: Want a computer application to control the appliances in a home Idea: Want a computer application to control the appliances in a home But - different chips on each But - different chips on each Need: Programming language that works on any machine Need: Programming language that works on any machine 3 years later, Internet hits, and we realize portability is a great idea… 3 years later, Internet hits, and we realize portability is a great idea…
7
How Java Programming Works 1. Programmer types a program into a text editor. This code is called the source code.This code is called the source code. It is saved as a file on your computer, much like any other file you create.It is saved as a file on your computer, much like any other file you create. Since the code is human- readable, it is usually kept private.Since the code is human- readable, it is usually kept private. public class Hello{ public static void main( String[] args){ System.out.println( “Hello World!”); }
8
How Java Programming Works 1. Source Code 2. The Java compiler reads the code and makes an intermediate code called bytecode. Again, this code is NOT human-readable. Again, this code is NOT human-readable. Again, this is what comes on software CDs, so that the code remains proprietary. Again, this is what comes on software CDs, so that the code remains proprietary. public class Hello{ public static void main( String[] args){ System.out.println( “Hello World!”); } 0: iconst_2 1: istore_1 2: iload_1 3: sipush 1000 6: if_icmpge 44 9: iconst_2 10: istore_2 11: iload_2 12: iload_1 13: if_icmpge 31 Java Compiler: Same for all machines
9
How Java Programming Works 1. Source Code 2. Compiled to Bytecode 3. Interpreted by JVM (Java Virtual Machine) This program reads bytecode and translates it directly to whatever machine code is needed. public class Hello{ public static void main( String[] args){ System.out.println( “Hello World!”); } _main _TEXT SEGMENT _argc$ = 8 _argv$ = 12 _main PROC NEAR ; COMDAT 00000 68 00 00 00 00 push OFFSET FLAT:??_C@_0M@KPLPPDAC@Hello?5World?$AA@ 00005 e8 00 00 00 00 call _printf 0000a 83 c4 04 add esp, 4 0000d 33 c0 xor eax, eax Interpreted by JVM Java Compiler: Same for all machines 0: iconst_2 1: istore_1 2: iload_1 3: sipush 1000 6: if_icmpge 44 9: iconst_2 10: istore_2 11: iload_2 12: iload_1 13: if_icmpge 31
10
How Java Programming Works 1. Source Code 2. Compiled to Bytecode 3. Interpreted by JVM to Machine Code 4. Executed by machine public class Hello{ public static void main( String[] args){ System.out.println( “Hello World!”); } _main _TEXT SEGMENT _argc$ = 8 _argv$ = 12 _main PROC NEAR ; COMDAT 00000 68 00 00 00 00 push OFFSET FLAT:??_C@_0M@KPLPPDAC@Hello?5World?$AA@ 00005 e8 00 00 00 00 call _printf 0000a 83 c4 04 add esp, 4 0000d 33 c0 xor eax, eax Interpreted by JVM Java Compiler: Same for all machines 0: iconst_2 1: istore_1 2: iload_1 3: sipush 1000 6: if_icmpge 44 9: iconst_2 10: istore_2 11: iload_2 12: iload_1 13: if_icmpge 31 Hello World!
11
Java Overview public class Hello{ public static void main(String[] args){ System.out.println(“Hello World!”); } _main _TEXT SEGMENT _argc$ = 8 _argv$ = 12 _main PROC 0: iconst_2 1: istore_1 2: iload_1 3: sipush 1000 Hello World! FLAT:??_C@_0M@ KPLPPDAC@Hello?5 World?$AA@ 00005 e8 00 00 00 00 0000a 83 NEAR ; COMDAT 0000 68 00 00 00 00 push 00005 e8 00 00 00 00 call 0000a 83 c4 04 add esp, 0000d 33 c0 xor eax, Source Code: MUST be named Hello.java Bytecode: will be saved as Hello.class Mac Whatever UnixWindows
12
So, what about Eclipse? What is eclipse? What is eclipse? How does it work? How does it work? What languages will it work for? What languages will it work for?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.