Cannot reference external types in Java

363 Views Asked by At

I'm trying to use the special type QuickUnionPathCompressionUF (which is a class in a file called algs4.jar), but the compiler complains. I'm using DrJava as an IDE.

error: QuickUnionPathCompressionUF cannot be resolved to a type

My source file (part of which is shown below) is here:

~/Percolation/Percolation.java

and the .jar file is here:

~/algs4/algs4.java

I have an environment variable (CLASSPATH) set to

~/algs4/algs4.jar ~/algs4/stdlib.jar

Both of these files are listed under "Extra Classpath" in my IDE.

Here are the first few lines of the source file.

package Percolation;

//import algs4.QuickUnionPathCompressionUF;

public class Percolation {

    private QuickUnionPathCompressionUF grid;    // Data structure for quick-union.
    private int size; // Size of the grid.
    private boolean[] open; // open sites 

/* ...*/

}

Any suggestions?

1

There are 1 best solutions below

0
On BEST ANSWER

You have commented out the import of this class. But since it is in another package, it has to be imported (or fully qualified) when you use it.