0

I'm very new to Java programming and I'm trying to add jar to the classpath like this:

javac -classpath ~/Downloads/algs4.jar. ThreeSum.java 

but still I'm getting the exception like:

ThreeSum.java:38: error: cannot find symbol
                        StdOut.println(a[i] + " " + a[j] + " " + a[k]);
                        ^
  symbol:   variable StdOut
  location: class ThreeSum
ThreeSum.java:62: error: cannot find symbol
        int[] a = In.readInts(args[0]);
                  ^
  symbol:   variable In
  location: class ThreeSum
ThreeSum.java:64: error: cannot find symbol
        Stopwatch timer = new Stopwatch();
        ^
  symbol:   class Stopwatch
  location: class ThreeSum
ThreeSum.java:64: error: cannot find symbol
        Stopwatch timer = new Stopwatch();
                              ^
  symbol:   class Stopwatch
  location: class ThreeSum
ThreeSum.java:66: error: cannot find symbol
        StdOut.println("elapsed time = " + timer.elapsedTime());
        ^
  symbol:   variable StdOut
  location: class ThreeSum
ThreeSum.java:67: error: cannot find symbol
        StdOut.println(cnt);
        ^
  symbol:   variable StdOut
  location: class ThreeSum
6 errors

I'm trying the programs from here

1

2 Answers 2

2

Looks like you need to download this JAR as well: http://introcs.cs.princeton.edu/java/stdlib/

They don't have a package structure, so unpack everything in the same directory:

jar xvf stdlib.jar
jar xvf algs4.jar

Then compile it:

javac -classpath . ThreeSum.java
Sign up to request clarification or add additional context in comments.

1 Comment

Or, to keep them in jars, -classpath .:stdlib.jar:algs4.jar .
1

You probably want ~/Downloads/algs4.jar. for that classpath to be ~/Downloads/algs4.jar:. on Linux or ~/Downloads/algs4.jar;. on Windows`

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.