簡體   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