> if classpath having not been set, how its possible
> for it to run from eclipse.
> read question again
Eclipse temporarily makes a classpath environment variable prior to the running of your program, and deletes that classpath after the run.. Same with NetBeans and others..
If you want to compile from the prompt, you'll need to manually tell java where the classpath is, and that is done by (as stated above):
java -cp "classpathdir" "classname"
> Ted
>
> if classpath having not been set, how its possible
> for it to run from eclipse.
> read question again
Ok, I read the question again. I came to the following conclusion; you are a fool.
Not only have you not bothered to do any searching for your problem but have also blatantly ignore the exception you received which tells you that the class can not be found on the classpath, ie. classpath not set or incomplete!!!!!
At least tribio is prepared to tend to the needs of fools.
Ted.
Since there have been a lot of posts from people who fail to compile and run their correct code, I would like to suggest to use ant for building and running! It hides the complexities of specifying the correct paths and a lot it's easier to type
prompt>ant
at the command line than
prompt>javac -d . -cp .;longListOfJarsNeededToRun somePackage/*.java aLotOfOtherFilesToCompile.java
prompt>java -cp .;longListOfJarsNeededToRun somePackage.someClass
It takes some time to get familiar with the configuration, but once you get it right, you gain back a lot of your invested time!