日食大整数编译问题



我正在使用Java 1.6.0_45。我有一个简单的Java代码,使用BigInteger。当我从命令行(javac,然后是java)运行时,它运行良好

现在,当我从 eclipse 运行相同的代码时,我收到编译错误!我在运行中打印了java版本,并且java运行时版本是相同的。

这是代码:

import java.math.*;
public class BigInteger2 {
     public static void main(String[] args) {
          System.out.println(System.getProperty("java.version"));
          BigInteger b1 = new BigInteger("3");
     }
}

我收到的错误(仅在Eclipse中)如下:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
The constructor BigInteger(String) is undefined at BigInteger2.main(BigInteger2.java:10)

它基本上是在抱怨新的BigInteger("3")

我在这里错过了什么?日食中的一些配置设置?为什么当我从命令行编译和调用时它运行良好,为什么它不能在 eclipse 中运行?请建议。谢谢!!

尝试清理并构建项目,然后运行程序

您在 Java->Install JRE 下的首选项中设置的 JDK/JRE 是什么?它与您在问题中提到的 JDK 相同吗?您是否可能将 eclipse.ini 中的 -vm 参数设置为较旧的 JDK?您可以在此处提供 -vm 参数,以确保使用正确的 JDK 来启动 eclipse 本身。[ http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html ]

转到您的project -> right click -> Properties -> java Build Path -> Libraries并检查您的JRE System Library版本

自 JDK 1.1 以来BigInteger存在,但不确定String constructor

最新更新