I am trying to use the stdlib.jar file provided in the link below:
http://introcs.cs.princeton.edu/java/stdlib/
I am having a lot of problems however in using the classes within this jar file. I'm not sure how to access the classes within this jar file because the file is not saved within a specific package of java, its just saved in a location within my netbeans folder. I tried looking at the following question:
Import custom libraries in Java
but I'm not sure what was meant by "adding the classpath while running" as well. What I have tried so far is adding the jar file directly to my project through netbeans - which didn't work - and I have tried creating a library that contained this jar file and adding the library to the project, which also doesn't work.
What I mean by doesn't work is that I cannot any of the classes from the jar file in my source code since the class is not recognized. Here is my relevant source code:
package plotproject;
public class Histogram {
private final double[] freq; // freq[i] = # occurences of value i
private double max; // max frequency of any value
// Create a new histogram.
public Histogram(int N) {
freq = new double[N];
}
// Add one occurrence of the value i.
public void addDataPoint(int i) {
freq[i]++;
if (freq[i] > max) max = freq[i];
}
// draw (and scale) the histogram.
public void draw() {
StdOut.println("Hello"); //shows error in netbeans "cannot find symbol StdOut
StdDraw.setYscale(0, max); //shows error in netbeans "cannot find symbol StdDraw
StdStats.plotBars(freq);//shows error in netbeans "cannot find symbol StdStats
}
}
How can I get the classes from the jar file to be used in my source code? Also, I already looked at the question Java, How to add library files in netbeans? before asking this, but I have already added the library to my project, so why is not being accessed in the source code?