I have a "MyCode.java" on my PC. In the code it uses a JDBC driver installed on my PC's "C" drive. So I included "C:\folder\jdbc\..." in the classpath and compiled the code to get "MyCode.class". Now I will need to move this "MyCode.class" to my friend's PC. In his machine the JDBC driver is installed on "D" drive and at a differently named folder. Of course he included "D:/another_folder\jdbc\.." in his classpath. Now, will the "MyCode.class" I created on my PC work in my friend's PC ?
Yes, as long as his CLASSPATH points to the driver classes, which will be needed at runtime. The .class files don't contain any path information regarded where they were created or where any other classes were located when the .class file was compiled.