views:

647

answers:

3

Hey, 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?

+1  A: 

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)

Brian Agnew
I get even stranger errors involving bash when I use semicolons.
mportiz08
You must quote the semicolon to avoid it being interpreted by Cygwin. For example, javac -cp .\;WordSearch.jar or javac -cp ".;WordSearch.jar"
bkail
@bkail - thanks. Now corrected
Brian Agnew
+1  A: 

You aren't importing any of the classes from your WordSearch.jar in your WordSearchSolver class. You need import statements at the top of this class including their package.

akf
As far as I know, the classes from WordSearch.jar aren't even in a package...
mportiz08
They're in the same package. They don't require importing
Brian Agnew
Brian, that wasnt clear in the example.
akf
A: 

It ended up being a combination of semicolons and quotation marks.

javac -classpath ".;WordSearch.jar" WordSearchSolver.java

Thanks everyone for pointing me in the right direction!

mportiz08