I am new to Java programming and Linux environment. And I am finding it difficult to understand few things about what is classpath, how does JVM locate classes, and JAVA API and many other things.
For example , today I wrote two simple classes 1)employee and 2) employeetest and placed them in the same folder. (employeetest has the "main" method and uses employee in its code.) I compiled employeetest and then executed it using "javac" command. I saw that , employee.class was also added to the folder. So does this mean that JVM automatically compiles all those files that are required for execution?
Then i placed the employee class outside the current directory , and then tried to execute employeetest. Now I got an error regarding ClassNotFound!!
why is it so? why didn't JVM search for the employee class in other directories?
The directory where I placed employee is also on my classpath or "PATH" in my linux? technically it should search for other directories also that are there in the PATH ?
correct me if I am wrong, because I am reading so many things on internet, I am not able to figure these concepts out clearly?
SO where does JVM search for the classes? In the same directory where the class with "main" is located?
On my machine when i do echo $JAVA_HOME nothing prints. but still my java and javac commands execute properly? why is it so? what is the meaning of $JAVA_HOME? where is JDK located? what are its functions?