繁体   English   中英

Eclipse BigInteger编译问题

[英]eclipse BigInteger compilation issue

我正在使用Java 1.6.0_45。 我有一个使用BigInteger的简单Java代码。 当我从命令行运行时(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中的某些配置设置? 当我从命令行编译和调用时,为什么它运行良好?为什么它不能在Eclipse中运行? 请提出建议。 谢谢!!

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

在Java-> Installed JRE's(首选项)下的Preferences(首选项)中设置的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

暂无
暂无

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

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