

I:\Sources> echo %classpath% -> It will display the value of classpath variable. You can also check whether the classpath has been correctly set or not using echo command. You can also avoid use of -classpath option each time you run java command by setting the classpath variable by using set classpath command. I:\Sources> java -classpath I:\Classes ProgramOne Syntax of java command with -classpath option is, class files saved in another folder is use -classpath option of java command. class file, you need to go to that location, again using CD command. If you run java command from this location, you will get an error saying could not find or load main class. I:\Sources> javac -d I:\Classes ProgramOne.java If you have not set the path environment variable, go through our previous concept to see how to set path environment variable. We have already set the path environment variable for the whole system, so no need to set it in the command prompt. >javac -d (Specify the path where to save generated. Syntax of javac command with -d option is, Now trigger the javac command with -d option. Open the command prompt and go to the location of. class file should be generated in another folder say I:\Classes (in my system)? This can be achieved using -d option of javac command. class file is generated in the same folder as that of.

Till now, we have seen, when you trigger javac command. I will save it in I:\Sources in my system. Type the above program in notepad and save it as “ProgramOne.java”. ("Setting Classpath Environment Variable") Today we will see how to set classpath and how to use javac command with -d option. In yesterday’s concept, we have seen how to set path environment variable.
