The Java Development Kit ( JDK 1 by pzs15406

VIEWS: 11 PAGES: 4

									The Java Development Kit

This contains the compiler to convert java source code to byte code, and the interpreter to
convert bytecode to machine language.

It is installed on each machine in the labs.

In the lab this week you will first create a directory ca591 on your h: drive into which
you will copy my sample programs and also the programs you create. Instructions for that
step will be given in your lab instructions. The notes below illustrate the compile stage .

Compiling the program

javac AddNumbers.java




note after this operation there will be a file AddNumbers.class on your directory




       Java source
     Java Source Code                   Java Compiler
       Code                                                            Java bytecode
       AddNumbers.java
                                                                       AddNumbers.Class




Running your program
java AddNumbers


                                               L2a-1
The java interpreter looks for the file AddNumbers.class and interprets and executes it


                                          Java Interpreter
       Java Bytecode
       Addnumbers.class                                                  Machinecode



Note the result of the execution - the output from your program.




NB.
 When calling the compiler you have a c at the end of java
   When calling the interpreter no c




The program ComputeNumbers.java




                                            L2a-2
Step through the code of the program ComputeNumbers.java and note what happens when
the program is executed.




Creating a source file
We can use any simple text editor. In the example below notepad is used. You will find it in the
accessories menu. In the lab you can use an editor called EditPlus which highlights java key
words. Details will be given in the handout in the lab on Wednesday.




                                             L2a-3
L2a-4

								
To top