next up previous contents
Next: Tomcat Up: The Java Environment Previous: Installing Java 2 SDK

Testing Java 2 SDK

Create a file called: that contains the following code:
   class HelloWorldApp { 
    public static void main (String args[]) { 
     System.out.println("Hello World!"); 
Compile the file with the command:
And run the file with the command:
   java HelloWorldApp
Here is an example of what I did:
   [rmorrien@escay rmorrien]$ javac
   [rmorrien@escay rmorrien]$ java
   Exception in thread "main" java.lang.NoClassDefFoundError: 
   [rmorrien@escay rmorrien]$ java HelloWorldApp
   Hello World!
   [rmorrien@escay rmorrien]$
As you can see I made the mistake to try to run the .java file and you must run the .class file with the java command, without adding the .class extension on the run line...

If this worked, then I presume the java environment is setup correctly! Now it's time to install Tomcat!

Copyright © 2001, R.M. Morriën, H.P.A.M. Snoek, M.A.C. Bakker