我是Java编程的新手,我正在尝试将jar添加到类路径中:
javac -classpath ~/Downloads/algs4.jar. ThreeSum.java
但我仍然得到例外:
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
我正在尝试here
中的程序答案 0 :(得分:2)
您似乎也需要下载此JAR:http://introcs.cs.princeton.edu/java/stdlib/
它们没有包结构,因此请将所有内容解压缩到同一目录中:
jar xvf stdlib.jar
jar xvf algs4.jar
然后编译它:
javac -classpath . ThreeSum.java
答案 1 :(得分:1)
您可能希望该类路径~/Downloads/algs4.jar.
在Linux上为~/Downloads/algs4.jar:.
或在Windows上为~/Downloads/algs4.jar;.