我想通过命令行在Snow Leopard上用javac编译。 我安装了Xcode。 我只是使用一个简单的Hello World文件,它在Eclipse中工作,但我无法使用javac使它工作。 javac -version返回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); } }我输入:javac HelloWorld.java
并得到以下错误。
HelloWorld.java:1: class, interface, or enum expected public class HelloWorld ^ 1 error和...
javac -cp。 HelloWorld.java
返回相同。
echo $ CLASSPATH只是返回空白。
谢谢您的帮助。
I am trying to compile with javac on Snow Leopard through the command line. I have Xcode installed. I am just using a simple Hello World file, it works in Eclipse but I can't 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 errorand...
javac -cp . HelloWorld.java
returns the same.
echo $CLASSPATH just returns blank.
Thanks for the help.
最满意答案
您是否正在使用UTF-8,并在文件的开始处使用字节顺序标记 ? 也许这是令人困惑的javac?
用十六进制编辑器查看文件,看看它是什么样子。
Are you using UTF-8 perhaps, with a byte order mark at the start of the file? Perhaps that's confusing javac?
Have a look at the file with a hex editor to see what it looks like.
更多推荐
发布评论