Java – Why can’t I compile the java file on cygwin, when it needs classes from a jar

classpathcygwinjarjavajavac

I'm trying to compile my class along with a provided .jar file which contains classes that my class will use.

This is what I've been trying:

javac -classpath .:WordSearch.jar WordSearchSolver.java

And this is the response:

WordSearchSolver.java:16: cannot find symbol
symbol  : class PuzzleWord
location: class WordSearchSolver
    public ArrayList<PuzzleWord> findwords()
                 ^
WordSearchSolver.java:18: cannot find symbol
symbol  : class PuzzleWord
location: class WordSearchSolver
    return new ArrayList<PuzzleWord>();
                         ^

2 errors

This is my class:

import java.util.ArrayList;

public class WordSearchSolver
{
    public WordSearchSolver(int size, char[][] puzzleboard, ArrayList<String> words)
    {

    }

    public ArrayList<PuzzleWord> findwords()
    {
        return new ArrayList<PuzzleWord>();
    }
}

WordSearch.jar contains:

PuzzleUI.class
PuzzleWord$Directions.class
PuzzleWord.class
Natural.class

(WordSearchSolver.java and Wordsearch.jar are in the same directory)

Am I missing something?

Best Solution

Although you're on Cygwin, I'm guessing that your path separator should be a semicolon, since the Java compiler/JVM will be running in a Windows environment.

javac -cp .\;WordSearch.jar ...

Note that the semicolon must be escaped to prevent interpretation by the Cygwin shell (thanks to bkail below)