简体   繁体   English

Java中的Hello World编译错误

[英]Hello World compiling error in Java

I try to compile HelloWorld on my Mac. 我尝试在Mac上编译HelloWorld。

public class HelloWorld {
    public static void main(String args[]) {
        System.out.println("Hello World!");
    }
}

I run from the terminal: 我从终端运行:

$javac HelloWorld.java

and I get 我得到

error: error reading /Users/gioelelamanno/Library/Java/Extensions/algs4.jar; 
cannot read zip file 1 error

Instead Eclispse compiles and run without problems. 取而代之的是,Eclispse可以毫无问题地编译并运行。 How can I fix it? 我该如何解决?

More than likely, the JAR file algs4.jar is corrupt. JAR文件algs4.jar很可能已损坏。 Either remove it from the classpath or get another copy if required for future compilation. 从类路径中将其删除,或者如果以后的编译需要,则获取另一个副本。 The JAR file can be downloaded here 可以在这里下载JAR文件

You need to create the .jar file within eclipse. 您需要在eclipse中创建.jar文件。 Once you save it, then you should be able to view it in the console. 保存后,您应该可以在控制台中查看它。 In this case, the terminal. 在这种情况下,终端。 I had this same issue. 我有同样的问题。 This is how I resolved it. 这就是我解决的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM