for compiling a java file,only path is enough know ?
the path variable tells your operating system (Windows, Unix, whatever...) where to look for programs you want to run. when you type "javac myClass.java", the OS says "hmmm... i need to find the javac.exe program. it's not in the current directory. let me check all the directories listed in the PATH environment variable (in the order they are listed) and see if i can find it."
that is the ONLY thing the PATH variable is used for. it really has nothing to do with how java works - it's only used to find the executables.
the CLASSPATH variable is used by the java programs to find various class files.
So, depending on what you are doing, you may not need to set either, you may need to set both, or you may need to set only one. although you're almost ALWAYS going to update your PATH to make life easier.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors