adne
adne

Reputation: 111

eclipse BigInteger compilation issue

I am using Java 1.6.0_45. I have a simple java code that uses BigInteger. It runs fine when I run from command line (javac and then java )

Now, when I run the same code from eclipse, I get a compilation error! I printed the version of java in both the runs and the java run time version is the same.

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 :

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")

What am I missing here? Some configuration setting in eclipse? Why does it run fine when I compile and invoke from command line and why doesnt it run in eclipse? please suggest. Thanks!!

Upvotes: 1

Views: 1561

Answers (3)

Sajan Chandran
Sajan Chandran

Reputation: 11487

Go to your project -> right click -> Properties -> java Build Path -> Libraries and check your version of JRE System Library

BigInteger is present since JDK 1.1, but am not sure about the String constructor

Upvotes: 0

user166566
user166566

Reputation:

What is the JDK/JRE you have set up in the Preferences under Java->Installed JRE's? Is it the same JDK you referring to in your question? Have you probably set the -vm parameter in your eclipse.ini to an older JDK? You may provide the -vm Parameter there to ensure that the right JDK is used to start eclipse itself. [ http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html ]

Upvotes: 1

upog
upog

Reputation: 5521

try clean and build the project and then run the prog

Upvotes: 1

Related Questions