CS1 for Java (Keyboard Input)
// File: InputTest.java
import cs1.Keyboard;
public class InputTest {
public static void main(String[] args) {
int i;
System.out.print("Type a number, followed by the Enter key: ");
i = Keyboard.readInt();
System.out.println("The number is: " + i);
}
}
It didn't work. I then opened the Keyboard.java file in DrJava, so both were open at the same time. Then, I was able to compile InputTest.java without a problem. But when I tried to run it, it gave me this error message: NoClassDefFoundError: cs1/Keyboard
at InputTest.main(InputTest.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
at java.lang.reflect.Method.invoke(Method.java:585)
I'm tearing my hair out trying to get this to work. Please help!
iMac G4 17", Mac OS X (10.4.7)