50 likes | 273 Views
Overview of Java. CSCI 392 Day One. Running C code vs Java code. C Source Code. Java Source Code. C Compiler. Java Compiler. Object File (machine code). Library Files. Java Byte Code. Java Platform (API). Linker. Java Virtual Machine (interpreter / JIT compiler).
E N D
Overview of Java CSCI 392 Day One
Running C code vs Java code C Source Code Java Source Code C Compiler Java Compiler Object File (machine code) Library Files Java Byte Code Java Platform (API) Linker Java Virtual Machine (interpreter / JIT compiler) Executable File (machine code) portable between machine types
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
Hello World 1.0 class hello { static void main (String[] args) { System.out.println("Hello World"); } } $ vi hello.java $ javac hello.java $ ls hello.class hello.java $ java hello Hello World
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]); } }