Reputation: 1417
Below is the program.. I tried after moving jars also... Is moving enough ? or any extra task to do with the jar files .
public class Stack {
public static void main(String[] args) {
while (!StdIn.isEmpty()) {
}
}
}
i moved necessary jar(stdlib.jar,algs4.jar ) files to lib ..... But it still showing the error.......
Stack.java:4: error: cannot find symbol while (!StdIn.isEmpty()) { ^ symbol: variable StdIn location: class Stack 1 error
Thanks in advance :)
Upvotes: 1
Views: 1377
Reputation: 719279
I don't know where you got this Stdin.isEmpty()
stuff from, but this does not bear any resemblance to any standard Java APIs.
The simple way to read from standard input in Java is to do something like this:
Scanner scanner = new Scanner(System.in);
and then call methods on the scanner
object to read stuff. Refer to the javadocs for Scanner
for details of how to use it.
On the other hand, if Stdin
is a real class that you have written, or that is defined in some 3rd-party library (maybe "stdlib.jar"?), then the problem is:
The procedure for adding something to the classpath depends on how you are building (i.e. compiling) the code, and how you are then running it.
Upvotes: 2
Reputation: 1391
StdIn
is not a Java keyword or class in the java.lang
package. In order to use a class defined in your jars you must include the jar in your classpath and import the package or class to your class.
Upvotes: 0
Reputation: 14715
You need to setup your classpath to use external java libraries
If you are using eclipse, you could Project - > Properties -> Java build path ->add Jar
.
That jar file should be placed in a directory inside your workspace (lib/
for example)
Upvotes: 1