Lesson 01 – An introduction to Java and the Java Programming Environment
1. background on the Java programming language
a. JDK – Java Development Kit. Necesssary to create a Java class
· JDK provides a compiler – javac.exe
b. JRE – Java Runtime Environment. Also referred to as the JVM – Java Virtual Machine
· JRE provides an interpreter – java.exe
c. A Java program must first be successfully compiled, then it can be interpreted to run the program
2. Java program types:
a. application command line / GUI
b. servlet runs on a web server
c. applet application that runs inside a web browser
3. introduction to Java Programming Concepts
· class
· global variables (aka fields or instance and class variables)
· method(s)
· method main – where execution always begins
· method main header: public static void main(String args[])
· statement(s)
4. keywords: special keywords used in Java are: class, public, static, void, import, throws
5. punctuation: ( ) [ ] { } , ; " " (String literal) ' ' (character literal)
6. frequently used classes: System, Math, String, Scanner, PrintWriter, JOptionPane
7. variables
a. global not declared inside of a method (must be outside of all methods)
b. local local variables are declared within a method (method level).
8. Java Development
a. code a source file
a source file is a file with an extension of .java that contains a class declaration
b. compile a source file to produce a class file
a class file is a file with an extension of .class that contains compiled Java source code
the JDK (Java Development Kit) is required to do this
c. a class file with a prescribed method main can be considered to be a program
the program must be run within the Java virtual machine (it is NOT the same as an executable program).
9. translation
a. compiling JDK command javac [ the JDK contains the Java compiler ]
example: javac HelloWorld.java [ produces HelloWorld.class ]
b. Interpreting JRE command java [ the JRE contains the Java interpreter ]
example: java HelloWorld [ runs HelloWorld.class ]
bytecode a successful compile in Java produces a .class file which contains "bytecodes"
10. platform independence ( "write once, run anywhere…" )
11. Using the command line to compile/run programs
a. javac [ used to invoke the compiler ] javac CarpentersCustomDesks.java
b. Java [ used to invoke the JVM to run a program ] java CarpentersCustomDesks
12. Check the version of your Java compiler (JDK) and interpreter (JRE)
a. Run cmd to bring up a command prompt
b. Enter the command “javac –version” to check the version of the compiler
c. Enter the command “java –version” to check the version of the interpreter