Lecture 2 Intro To Java

Lecture 2 Intro To - CMPT 125 Lecture 2 Introduction to Java Tamara Smyth tamaras@cs.sfu.ca School of Computing Science Simon Fraser University

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMPT 125: Lecture 2 Introduction to Java Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Brief History of Java • Java was developed by James Gosling and his team at Sun Computers in the early 1990s. • Originally called Oak, later given the name Java: – inspired by a coffee bean? – or an acronym for the names of the team members: J ames Gosling, A rthur V an Hoff, and A ndy Bechtolsheim? • Though now often thought of as a program designed for the world wide web, it was originally meant to be a programming language for embedded systems. • As the web gained in popularity in 1994, the HotJava browser was a good demo of Java’s capabilities: platform independence and security. • Java released publicly in 1995. CMPT 125: Introduction to Java, Lecture 2 2 Java Versions • We will use Java version 1.5 (5.0) which includes some major enhancements to previous versions of Java (so watch out for this if you’re using older textbooks!). • Regularly consult the following website (keep it bookmarked!) for the API specification: http://java.sun.com/j2se/1.5.0/docs/api/. CMPT 125: Introduction to Java, Lecture 2 3 Some Java Details • Java syntax is (purposely) similar to C/C++ syntax. • Java supports the object-oriented programming paradigm (OOP). • Because of OOP, some simple programs tend to be overly complex in Java. • Java was not designed with beginners in mind, but it is arguably easier to learn than C/C++. • Java uses a garbage collector to help manage memory. • For some applications Java is a little slower than C/C++ but tends to be much faster than (say) Python. CMPT 125: Introduction to Java, Lecture 2 4 Translating and Executing Java Programs • All source code is first written in plain text files ending with the .java extension. • Source files are then compiled to produce .class files. • A .class file does not contain code that is native to your processor. Rather, it contains bytecode , the machine language of the Java Virtual Machine (Java VM). • The java launcher tool then runs your application with an instance of the Java VM. Figure 1: MyProgram.java is compiled to produce MyProgram.class, which is then inter- preted by the Java VM before My Program runs on a computer. CMPT 125: Introduction to Java, Lecture 2 5 Platform Independence • Because the Java VM is available on many different operating systems, the same .class files can run on different computers without recompiling. • The Java HotSpot virtual machine, perform additional steps at runtime to give your application a performance boost, including recompiling some frequently used code to native machine code....
View Full Document

This note was uploaded on 12/07/2010 for the course CMPT 125 taught by Professor Diana during the Spring '08 term at Simon Fraser.

Page1 / 7

Lecture 2 Intro To - CMPT 125 Lecture 2 Introduction to Java Tamara Smyth tamaras@cs.sfu.ca School of Computing Science Simon Fraser University

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online