Return to the index page

Read articles about movies and Java

View a collection of Java games and software

Find statistics and reviews on popular movies

Enjoy book reviews, links and more

Creating An Application


Applications have the greatest range of uses RealMedia Java(tm) applications are more general programs written in the Java language. Java applications do not need a browser to run. Java can be used to create applications that you would normally use a more conventional programming language to create. HotJava itself is a Java application.

Java source files are created in a plain text editor, or an editor that saves plain ASCII files without character formatting. Some examples include Notepad or DOS edit.

It is almost mandatory that the first program you write in a new language prints "Hello, world" to the screen. Open your text editor and type in this program as shown:

class Hello2 
{
      public static void main(String args[]) 
      {
            System.out.println("Hello, world");
      }
}

This program has two parts: a class called Hello2 and the body of the program contained in a method called main().

Once you finish typing, save the file as "Hello2.java". Java files are usually saved with the same name as the class name with the extension ".java". To compile your program, you need a Java compiler. The compiler in Sun's JDK is called javac. Make sure javac is in your execution path then type the following:

javac Hello2.java

If you get a error when you compile, correct any typing mistakes you made before compiling again. You end up with a Java byte code file called "Hello2.class" in the same directory as your source file. Java byte codes are instructions written for a virtual Java machine. You can run this file using a java interpreter. The interpreter in the JDK is called java. Make sure java is in your execution path then type the following:

java Hello2

If your program was type and compiled correctly, the string "Hello, world" should be printed on your screen.

Next article


Return to the top of the page
| Home | Library | Applets | Movies | Plaza |

Please send any feedback to David Chan
1