Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

1 2 java development


Published on

  • Be the first to comment

  • Be the first to like this

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:// </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:// </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 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>