Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error #51

Open
gongzelong0718 opened this issue Apr 17, 2018 · 5 comments
Open

Build error #51

gongzelong0718 opened this issue Apr 17, 2018 · 5 comments

Comments

@gongzelong0718
Copy link

gongzelong0718 commented Apr 17, 2018

Does anyone know how to fix the build error?

➜  algs4 git:(master) ✗ javac BinarySearch.java
BinarySearch.java:94: error: cannot find symbol
        In in = new In(args[0])
        ^
  symbol:   class In
  location: class BinarySearch
BinarySearch.java:94: error: cannot find symbol
        In in = new In(args[0]);
                    ^
  symbol:   class In
  location: class BinarySearch
BinarySearch.java:101: error: cannot find symbol
        while (!StdIn.isEmpty()) {
                ^
  symbol:   variable StdIn
  location: class BinarySearch
BinarySearch.java:102: error: cannot find symbol
            int key = StdIn.readInt();
                      ^
  symbol:   variable StdIn
  location: class BinarySearch
BinarySearch.java:104: error: cannot find symbol
                StdOut.println(key);
                ^
  symbol:   variable StdOut
  location: class BinarySearch
5 errors
@asarkar
Copy link

asarkar commented May 11, 2018

I'm using the version 1.0.3 from Bintray and it seems to be working so far. No one could help you unless you clearly describe how you're building, and what you're building. Better yet, attach a sample project along with steps to reproduce the problem.

@HuangStomach
Copy link

I think you need to:

 import edu.princeton.cs.algs4.*

我猜你没有引入该书提供的工具库

@hanyun2019
Copy link

I passed the compile part:
javac -cp /Users/user/documents/algorithms/algs4-master/target/algs4-1.0.0.0.jar BinarySearch.java

But failed in the run part:
java BinarySearch

The error message is:
Kelvin-Mac:java user$ java BinarySearch
Error: Could not find or load main class BinarySearch
Caused by: java.lang.ClassNotFoundException: BinarySearch

Anyone what happens to me? Thanks~

@hanyun2019
Copy link

I know how to compile and run it now:
javac -cp /Users/user/documents/algorithms/algs4-master/target/algs4-1.0.0.0.jar BinarySearch.java

java -cp /Users/user/documents/algorithms/algs4-master/target/algs4-1.0.0.0.jar edu.princeton.cs.algs4.BinarySearch tinyW.txt < tinyT.txt

@hanyun2019
Copy link

The correct solution is:

javac -cp /Users/user/documents/algorithms/algs4-master/target/algs4-1.0.0.0.jar -d . BinarySearch.java

java -cp /Users/user/documents/algorithms/algs4-master/target/algs4-1.0.0.0.jar edu.princeton.cs.algs4.BinarySearch tinyW.txt < tinyT.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants