Running a program <ul><li>Compiling </li></ul><ul><ul><li>A program, called a  compiler , translates the source code into ...
Java Code Execution <ul><li>Compiler (javac) translates source code (.java file) to byte code (.class file) </li></ul><ul>...
Java Pyramid Application or Applet Class Class Project Data Methods Data Instructions
Java Development <ul><li>JDK 1.6.20 SE Development Kit (JDK) </li></ul><ul><ul><li>http:// java.sun.com/javase/downloads/i...
Hello, world!! <ul><li>Class </li></ul><ul><li>Methods </li></ul><ul><ul><li>main </li></ul></ul><ul><li>Comments </li></u...
Classes and Objects <ul><li>A class is a  definition  of a (complex) data type </li></ul><ul><li>An object is an  instanti...
Special method: main <ul><li>Methods </li></ul><ul><ul><li>A collection of data and  instructions </li></ul></ul><ul><ul><...
Comments <ul><li>Notes to other readers of your software (including your teacher and yourself). </li></ul><ul><li>Ignored ...
Blocks <ul><li>A section of code; a set of instructions or statements. </li></ul><ul><li>A block starts with ‘{‘, and ends...
Lab 0: Hello, world
Lab 0 debrief: What have we discovered? <ul><li>We created an  application  called  Hello </li></ul><ul><li>The software w...
Upcoming SlideShare
Loading in …5
×

1 2 java development

469
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
469
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

1 2 java development

  1. 1. Running a program <ul><li>Compiling </li></ul><ul><ul><li>A program, called a compiler , translates the source code into machine code </li></ul></ul><ul><ul><li>The CPU then executes the machine code </li></ul></ul><ul><ul><li>C, FORTRAN, Pascal, COBOL, BASIC </li></ul></ul><ul><li>Interpreting </li></ul><ul><ul><li>A program, called an interpreter, reads the source code and executes the instructions </li></ul></ul><ul><ul><li>BASIC, LISP, Perl, Python </li></ul></ul>
  2. 2. Java Code Execution <ul><li>Compiler (javac) translates source code (.java file) to byte code (.class file) </li></ul><ul><li>Byte code is machine independent </li></ul><ul><li>Byte code is interpreted by the Java run-time program program (java), the IDE (BlueJ), the appletviewer, or the web browser. </li></ul><ul><li>The program can be compiled on one machine and interpreted on another. </li></ul>
  3. 3. Java Pyramid Application or Applet Class Class Project Data Methods Data Instructions
  4. 4. Java Development <ul><li>JDK 1.6.20 SE Development Kit (JDK) </li></ul><ul><ul><li>http:// java.sun.com/javase/downloads/index.jsp </li></ul></ul><ul><ul><li>Includes compiler, interpreter, and libraries </li></ul></ul><ul><li>BlueJ </li></ul><ul><ul><li>Version 3 </li></ul></ul><ul><ul><li>IDE (Integrated Development Environment) </li></ul></ul><ul><ul><li>Tools for designing, developing, and testing Java software. </li></ul></ul><ul><ul><li>http:// bluej.org </li></ul></ul>
  5. 5. Hello, world!! <ul><li>Class </li></ul><ul><li>Methods </li></ul><ul><ul><li>main </li></ul></ul><ul><li>Comments </li></ul><ul><ul><li>javadocs </li></ul></ul><ul><li>Blocks </li></ul>
  6. 6. Classes and Objects <ul><li>A class is a definition of a (complex) data type </li></ul><ul><li>An object is an instantiation of a class </li></ul><ul><li>A Java program is a set of interacting objects </li></ul><ul><li>Everything in Java is an object </li></ul>
  7. 7. Special method: main <ul><li>Methods </li></ul><ul><ul><li>A collection of data and instructions </li></ul></ul><ul><ul><li>Has a specific purpose </li></ul></ul><ul><li>public static void main(String args) </li></ul><ul><ul><li>The start of a Java application </li></ul></ul><ul><ul><li>It must belong to a class </li></ul></ul><ul><ul><li>(We will cover applets after we’ve covered objects and classes) </li></ul></ul>
  8. 8. Comments <ul><li>Notes to other readers of your software (including your teacher and yourself). </li></ul><ul><li>Ignored by the machine. </li></ul><ul><li>Two formats: </li></ul><ul><ul><li>“/*” starts a comment, ‘*/’ finishes it. These comments can span multiple lines. </li></ul></ul><ul><ul><li>‘//’ starts the comment, EOL (end-of-line) finishes it. </li></ul></ul><ul><li>Comments can be inserted anywhere, but there are some common locations. </li></ul>
  9. 9. Blocks <ul><li>A section of code; a set of instructions or statements. </li></ul><ul><li>A block starts with ‘{‘, and ends with ‘}’ </li></ul><ul><li>Blocks are written for: </li></ul><ul><ul><li>Method definitions </li></ul></ul><ul><ul><li>Class definitions </li></ul></ul><ul><ul><li>Loops </li></ul></ul><ul><ul><li>‘then’ and ‘else’ bodies </li></ul></ul><ul><li>Blocks also define scope for variables. </li></ul>
  10. 10. Lab 0: Hello, world
  11. 11. Lab 0 debrief: What have we discovered? <ul><li>We created an application called Hello </li></ul><ul><li>The software was created in a folder in My Documents also called Hello </li></ul><ul><li>The folder has a file called Hello.java containing: </li></ul><ul><ul><li>A Class called Hello </li></ul></ul><ul><ul><li>The main method, the applications starting point. </li></ul></ul><ul><li>The compiler creates a file called Hello.class containing the program’s byte code. </li></ul><ul><li>We were able to do everything using BlueJ </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×