Reputation: 81
I'm trying to benefite from the EnumeratedIntegerDistribution()
from org.apache.commons.math3.distribution
, as shown below.
I'm working wiht jdk7 , on windows Xp, running from Command Line, in one and only project folder
I do:
import java.lang.Math.*; import org.apache.commons.math3.distribution.EnumeratedIntegerDistribution;
public class CheckMe {
public CheckMe() {
System.out.println("let us check it out");
System.out.println(generate_rand_distribution (10));
}
private static int[] generate_rand_distribution (int count){
int[] nums_to_generate = new int[] { -1, 1, 0 };
double[] discrete_probabilities = new double[] { 0.4, 0.4, 0.2 };
int[] samples = null;
EnumeratedIntegerDistribution distribution =
new EnumeratedIntegerDistribution(nums_to_generate, discrete_probabilities);
samples = distribution.sample (count);
return (samples);
}
public static void main (String args[]) {
System.out.println("Main: ");
CheckMe animation = new CheckMe();
}
}
However I have got:
ClassNotFoundException: org.apache.commons.math3.distribution.EnumeratedIntegerDistribution at line 18 - the call for EnumeratedIntegerDistribution()
If I run as I was just advised (below):
java -cp commons-math3-3.2/commons-math3-3.2.jar CheckMe
I get error: impossible to find the principle class CheckMe
Thanks a lot in advance for your advise.
Upvotes: 0
Views: 1912
Reputation: 280168
You need to specify the classpath both when you compile and when you run. So running
java CheckMe.java
is not enough. Also it should be
java CheckMe
assuming the class CheckMe
is not in any package.
You need to execute
java -cp commons-math3-3.2/commons-math3-3.2.jar CheckMe
specifying the jars and other classes your CheckMe
program needs.
Upvotes: 2