The problem is that you're trying to instantiate a java.lang.String object (look at the parameters in main()) and you're not including the java.lang.String class.
Open your text editor of choice (I use TextWrangler) and try this:
Code:
import java.lang.String;
class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello, world!");
}
}
Save that as "HelloWorld.java" (no quotes) to your desktop. Notice that the "HelloWorld" class declaration matches the pre-extention "HelloWorld" in the filename. This is case sensitive and they MUST match.
Next, open Terminal.app (Applications / Utilities / Terminal.app) and type in these commands:
Code:
cd ~/Desktop
javac HelloWorld.java
java HelloWorld
The first command, cd ~/Desktop, should be self-explanatory. The second, javac HelloWorld.java, calls the
java compiler to compile your .java file into a .class file.
The final command, java HelloWorld, tells the Java runtime executable (aka JVM) to load HelloWorld.class, find the main() method, and run it.
If this is over your head, I strongly suggest picking up one of the "... for Dummies" books and going from there. Learning a language and powerful and complex as C or Java w/out a book or something is really painful.
Good luck.