简体   繁体   English

Eclipse BigInteger编译问题

[英]eclipse BigInteger compilation issue

I am using Java 1.6.0_45. 我正在使用Java 1.6.0_45。 I have a simple java code that uses BigInteger. 我有一个使用BigInteger的简单Java代码。 It runs fine when I run from command line (javac and then java ) 当我从命令行运行时(javac然后是java),它运行良好

Now, when I run the same code from eclipse, I get a compilation error! 现在,当我从eclipse运行相同的代码时,出现编译错误! I printed the version of java in both the runs and the java run time version is the same. 我在运行中打印了Java版本,并且Java运行时版本相同。

Here is the code: 这是代码:

import java.math.*;

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

The error (only in Eclipse) that I get is the following : 我得到的错误(仅在Eclipse中)如下:

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

It is basically complaining about new BigInteger("3") 基本上是在抱怨新的BigInteger(“ 3”)

What am I missing here? 我在这里想念什么? Some configuration setting in eclipse? Eclipse中的某些配置设置? Why does it run fine when I compile and invoke from command line and why doesnt it run in eclipse? 当我从命令行编译和调用时,为什么它运行良好?为什么它不能在Eclipse中运行? please suggest. 请提出建议。 Thanks!! 谢谢!!

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

What is the JDK/JRE you have set up in the Preferences under Java->Installed JRE's? 在Java-> Installed JRE's(首选项)下的Preferences(首选项)中设置的JDK / JRE是什么? Is it the same JDK you referring to in your question? 您在问题中使用的是同一个JDK吗? Have you probably set the -vm parameter in your eclipse.ini to an older JDK? 您是否已将eclipse.ini中的-vm参数设置为较旧的JDK? You may provide the -vm Parameter there to ensure that the right JDK is used to start eclipse itself. 您可以在此处提供-vm参数,以确保使用正确的JDK来启动Eclipse本身。 [ http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html ] [ http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html ]

Go to your project -> right click -> Properties -> java Build Path -> Libraries and check your version of JRE System Library 转到您的project -> right click -> Properties -> java Build Path -> Libraries然后检查您的JRE System Library版本

BigInteger is present since JDK 1.1, but am not sure about the String constructor 自JDK 1.1起就存在BigInteger ,但不确定String constructor

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

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