5
Overview of Java CSCI 392 Day One

Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File

Embed Size (px)

Citation preview

Page 1: Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File

Overview of Java

CSCI 392

Day One

Page 2: Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File

Running C code vs Java code

C Source Code

C Compiler

Object File(machine code)

LibraryFiles

Linker

Executable File(machine code)

Java Source Code

Java Compiler

Java Byte Code

Java Platform(API)

Java Virtual Machine(interpreter / JIT compiler)

portable between machine types

Page 3: Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File

Java Design Features

Byte Code is machine independent

Network-Centric provides OS-type services security is a fundamental concern

Java 5.0 includes 3562 classes in 166 packages, including support for client-server operation concurrency parsing web data etc

Page 4: Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File

Hello World 1.0

class hello{ static void main (String[] args) { System.out.println("Hello World"); }}

$ vi hello.java$ javac hello.java$ lshello.class hello.java$ java helloHello World

Page 5: Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File

Hello World 1.1

public class hello2{ public static void main (String[] args) { int num_loops; // numbers of hellos to print

// test the user input if (args.length != 2) { System.out.println("Usage Error: java hello2 name count"); return; }

// convert the command line arg from string to int num_loops = Integer.parseInt (args[1]);

// print the hellos for (int i=0; i<num_loops; i++) System.out.println("Hello " + args[0]); }}