To run a java program we need to set "path" and "classpath".
1. Path : path can use to find executable file. here we specify required all executable file. that means .exe files. e.g. java.exe, javac.exe, javadoc.exe, jar.exe etc .
2. classpath: classpath is used to specify to find class files.
Let's Do Practically
Set Path from command prompt
Step 1 : Open Cmd (Command Prompt)Step 2 : Type : set path=C:\Program Files\Java\jdk1.8.0_121\bin ; . ;
Step 3 : Hit Enter
Note - bin folder contains all executable file.
Don't forget to give semi-colon(;) then . (dot) and then semicolon(;)
let's check it
try to run any java command like jar javac. javadoc etc (without parameters)
let me show you one of them , how to get java version . for this run following command
cmd=> C:\Users\Gstar>;java -version
(Hit Enter)
(Hit Enter)
Set classpath from command prompt
Step 1 : Open Cmd (Command Prompt)Step 2 : Type : set classpath=C:\Program Files\Java\jdk1.8.0_121\bin ; . ;
Step 3 : Hit Enter
Note - rt.jar contains java classes in form of archive file .
Don't forget to give semi-colon(;) then . (dot) and then semicolon(;)
Run any simple java program for test purpose
Done!