I am attempting to use Apache Commons Math 3.3 for a static data processing class, and am using Eclipse Mars to create it. I have successfully downloaded the bin and src files, and added them to the build path of my project; I can see them in my JRE System Library. I have also added the javadoc URL in the 'Javadoc Location' tab. I am successful in importing classes from the library.
However, when I attempt to instantiate an object from AC-M, Eclipse is unable to resolve that object as a type. For instance,
import org.apache.commons.math3.stat.descriptive.SummaryStatistics.*;
public class Stats {
public static double mean(double[] data) {
SummaryStatistics curr = new SummaryStatistics();
for (int a = 0; a < data.length; a++) {
curr.addValue(data[a]);
}
double mn = curr.getMean();
return mn;}
}
The import statement works fine. However, immediately Eclipse reads an error in my 4th line of code:
SummaryStatistics cannot be resolved to a type
This occurs for all other objects, e.g. PearsonsCorrelation
, SimpleRegression
, etc. (I successfully import the respective portions of the library for all objects.) Eclipse offers an option to 'Fix project setup..', yet upon clicking, no solutions are available. I have cleaned the buildpath to no avail. I would appreciate assistance in fixing this problem.
EDIT: I added the jar files by selecting the package of interest and clicking Properties>JRE System Library [jre8] Edit...>Installed JREs...>Edit...>Add External JARs...then adding commons-math3-3.3.jar to the library.
This import:
import org.apache.commons.math3.stat.descriptive.SummaryStatistics.*;
doesn't import SummaryStatistics
itself, just any classes defined within that class. Add:
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
as well.