I am trying to compile using javac on Snow Leopard via the command line. I have Xcode installed. I just use a simple Hello World file, it works in Eclipse, but I cannot get it to work using javac.
javac -version returns javac 1.6.0_17
HelloWorld.java
public class HelloWorld
{
public static void main(String[] args)
{
String message = "Welcome to Java!";
System.out.println(message);
}
}
I type: javac HelloWorld.java
and get the following error.
HelloWorld.java:1: class, interface, or enum expected
public class HelloWorld
^
1 error
and...
javac -cp. HelloWorld.java
returns the same.
echo $ CLASSPATH just returns empty.
Thanks for the help.
source
share