This might be a very simple problem indeed, but I am absolutely new to Java, and not getting how to resolve it.
I have a stdlib.jar file which has some Classes defined like StdRandom and I have to to use them in my program. I read, that to use files like stdlib.jar I have to use the default package. So I removed the "package algs4" from my program below. But it didn't work.
package algs4;
public class PercolationStats
{
//Some method declarations
public static void main(String[] args)
{
//Some code
for(int counter=0; counter<T; counter++)
{
while(!p.percolates())
{
iIndex = StdRandom.uniform(N);
jIndex = StdRandom.uniform(N);
...
}
}
}
Every time I compile this program using:
javac -cp . algs4/PercolationStats.java
I get the error:
algs4/PercolationStats.java:30: cannot find symbol
symbol : variable StdRandom
location: class algs4.PercolationStats
iIndex = StdRandom.uniform(N);
I also tried to compile using:
javac -cp .:stdlib.jar algs4/PercolationStats.java
But the error remains same.
Though it is not a good practice, I also extracted the files from the .jar file, which gave me the StdRandom.java file, but it still doesn't work.
All my files including the stdlib.jar are in the same directory.
How should I go about it?
EDIT: Just to make the question more elaborate for any future references: stdlib.jar used in the program was in a "default" package.