02-java-programming-basics

02-java-programming-basics - Java Programming Basics CSE...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Programming Basics CSE 114: Computer Science I SUNY at Stony Brook 1
Image of page 1

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

View Full Document Right Arrow Icon
Outline of Topics The Java Environment Java Grammar A First Program Parts of a Java Program Compiling and Executing Java Code Experimenting With Code 2
Image of page 2
The Java Development Cycle Standard edit-compile-execute cycle Compilation translates source code into a form that the computer can understand With Java, this is slightly more complicated than with other languages... 3
Image of page 3

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

View Full Document Right Arrow Icon
Two Faces of Java The name “Java” actually refers to two things: The programming language The Java Virtual Machine (JVM) In most languages, a compiled program runs directly on the hardware (it speaks the CPU’s language) Java programs execute on a simulated CPU (the JVM). The real CPU runs a program that simulates this CPU. 4
Image of page 4
Desktop PC Source Code is compiled by executes program on The Java Compilation Process 5
Image of page 5

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

View Full Document Right Arrow Icon
Java Compilation (Part 1) Desktop PC Source Code is compiled by executes program on Source Code 100111 101010 110011 000110 Java Bytecode Java compiler (javac) 6
Image of page 6
Java Compilation (Part 2) Desktop PC Source Code is compiled by executes program on 100111 101010 110011 000110 Java Bytecode Java Virtual Machine (JVM) Desktop PC executes on which is simulated by 7
Image of page 7

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

View Full Document Right Arrow Icon
Why Is It So Complicated? With most languages, a program must be compiled separately for every type of CPU A new type of CPU requires another compilation Java programs are compiled to a fake CPU (the JVM) After one compilation, a Java program can run on any CPU that can run the JVM “Write once, run anywhere” reduces programmer effort 8
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern