I have just copied Key-Listener code from http://java.sun.com/docs/books/tutorial/uiswing/examples/events/KeyEventDemoProject/src/events/KeyEventDemo.java. I was able to compalie it with the "javac" command. But when I try to execute the compiled code (typing "java KeyEventDemo") I have a large message in the end of which I see:
Could not find the main class: KeyEventDemo. Program will exit.
Yesterday I had a similar problem on Windows Vista (now I am on Ubuntu). In the Windows I was able to solve the problem by typing "java -cp . ProgramName" or alternatively by adding new values ("." and "..")to the environment variable "classpath".
On Ubuntu the first solution does not work. I mean, when I type "java -cp . KeyEventDemo" I still have the problem. Moreover, on Ubuntu I was able to run other programs just typing "java ProgramName".
So, can anybody tell me what is special about this KeyEventDemo? Why it does not wont to work and how it can be solved?