Friday, June 13, 2008

Java Programming Language

The Java Programming Language course provides students with information about the syntax of the Java programming language; object-oriented programming with the Java programming language; creating graphical user interfaces (GUIs), exceptions, file input/output (I/O), and threads; and networking. Programmers familiar with object-oriented concepts can learn how to develop Java technology applications. The course features the Java Platform, Standard Edition 6 (Java SE 6) platform, and utilizes the Java SE Development Kit 6 (JDK 6) product. The students perform the course lab exercises using the JBuilder Integrated Development Environment (IDE).


HelloWorld
Java JDK on your system (check first, there may already be one.. look for an executable called javac or javac.exe). Look for the highest version number that does not end in RC (for release candidate). Make sure to download the JDK (Java Development Kit), not the JRE (Java Runtime Environment). The develepment kit includes the java compiler. Install the JDK as described in the release notes for your platform.

In your favorite editor, create a file called HelloWorld.java with the following contents:

class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World!");
}
}



From a command line, the command to compile this program is:

javac HelloWorld.java


For this to work, the javac must be in your shell's path or you must explicitly specify the path to the program (such as c:\j2se\bin\javac HelloWork.java). If the compilation is successful, javac will quietly end and return you to a command prompt. If you look in the directory, there will now be a HelloWorld.class file. This file is the compiled version of your program.

To run the program, you just run it with the java command:

java HelloWorld


It is important to note that you use the full name with extension when compiling (javac HelloWorld.java) but only the class name when running (java HelloWorld).