140 likes | 279 Views
CIS 103 – Programming Logic and Design. Java PAL. Java Development Kit. Contains the development kit and the runtime environment ( aka the Java Virtual Machine ) Download Link: http://java.sun.com/javase/downloads/index.jsp Installation
E N D
Java Development Kit • Contains the development kit and the runtime environment ( aka the Java Virtual Machine ) • Download Link: http://java.sun.com/javase/downloads/index.jsp • Installation • Detailed instructions in the “Read This Before You Begin” section. • Environment Variables • Path • Classpath
The Java Programming Language • Originally was to be called “Oak” • Open Source Software ( free!! )
Platforms • Mainframes, minicomputers, servers, desktops, notebooks, mobile devices, intelligent consumer devices • Windows, Linux, Unix, Macintosh, etc.
Java API • Application Programming Interface • Class Library • Packages • Classes • Methods • Statements • http://java.sun.com/javase/6/docs/api/
Java Applications • Application • A stand-alone program that runs on a computer. • Applet • An applet is a Java program that is executed and viewed in a browser ( IE, Firefox, Navigator, etc. ) • Servlet • A servlet is a Java program that runs on a Web server or application server and provides server-side processing such as accessing a database and e-commerce transactions.
Objects • An object represents something in the real world, such as a car, an employee, or an item in an inventory. • Objectsencapsulateattributes and behavior • An attribute is a piece of information • A behavior is an operation that may be used to manipulate the value of an attribute
Objects • Reusable software components that model real-world items • Look all around you • People, animals, plants, cars, etc. • Attributes • Size, shape, color, weight, etc. • Behaviors • Babies cry, crawl, sleep, etc. • Even though Java is an object-oriented programming language, we will be doing procedural programming using the language. In the CIS 182/282 courses you will explore object-oriented programming in Java.
Java Development • Java programs go through five phases: • Edit • Programmer writes program using an editor; stores program on disk with the .java file name extension • Compile • Use javac (the Java compiler) to create bytecodes from source code program; bytecodes stored in .class files • Load • Class loader reads bytecodes from .class files into memory • Verify • Bytecode verifier examines bytecodes to ensure that they are valid and do not violate security restrictions • Execute • Java Virtual Machine (JVM) uses a combination of interpretation and just-in-time compilation to translate bytecodes into machine language
Classes • Classes are the fundamental unit of programming in Java. • Classes may be composed of: • variables corresponds to attributes • methods corresponds to behaviours
Simple Java Class Example public class HelloWorld { public static void main(String args[]) { System.out.println(“Hello World!”); } } • class is: HelloWorld • method is: main • header: public static void main(String args[])
Java Class Translation • A translator translates a program (class) in one language into another (often a machine language). • A translator may be a: • compiler translate only • interpreter translate and execute • Java uses both a compiler and an interpreter ( as do applications in the Visual Studio environment )
Java .class Files • If you successfully compile a Java class, you produce a class file. This is a file with the same name as the program but with a .class extension • A Class file contains an intermediate language or virtual machine language. In Java this intermediate language is called bytecode.