I had a java file which need to be compiled and it was present in some other directory, i can compile it simply by specifying the full path where the java file is located but my problem is can i compile it by mentioning path to that java file in classpath
Yes you can compile a java file using classpath to compile a file that is present in some other location. From cmd, you first need to set the directory where your java file is located , for e.g.: if my file is in D directory then my cmd command prompt should be D:/ and the you can set path to your bin folder of java.