We need to set jdk bin path to complie and java source code.
if Java source file is inside the JDK/bin directory, then you don't need to set path of java because all the tools will be available in the current directory.
if your Java file is outside the JDK/bin folder, it is necessary to set the path of JDK.
You can set the path in Java by two ways as below.
- Temporary
- Permanent
1) How to set the Temporary Path of JDK in Windows?
- Open the command prompt
- Copy the path of the JDK/bin directory
- Write in command prompt: set path=jdk_bin_path
Example,
set path=C:\Program Files\Java\jdk-19\bin
Look at below screeshots.
2) How to set the Permanent Path of JDK in Windows?
Go to MyComputer properties -> advanced tab -> environment variables -> new tab of user variable -> write path in variable name -> write path of bin folder in variable value -> ok -> ok -> ok
Look at below screenshots,
How to set Java Path in Linux OS ?
you can use below command in linux to set java path in linux OS.
export PATH=$PATH:/home/jdk-19/bin/
Comments