Scanner class Methods in Java

Java Environment Setup:- 2) Setting Environment Variable Path

Setting Environment Variable Path

In the previous post we learned about downloading and installing JDK. If you haven't read that post, Click here.

It is very important to set the environment variable in your system to run java. If you don't set the path then whenever you'll try to compile & run java program in Command Prompt, it will display error as follows:- 
javac error in command prompt or cmd
javac command is use to compile java programs. It invokes the java compiler. We'll learn about these commands while writing java programs.

To solve the above error we need to set Environment variable. So lets begin,

Steps:-

  1. Go to Control Panel  of your computer, write Env in search box of control panel OR just type Env at Start search bar.
  2. Click on the marked area as show below:- There are two links click any. 
    Open Advance Settings or Environment Variable settings using Control Panel

  3. The Advance Setting Dialog Box appears, Click on Environment Variables. 
    Click on Environment Variable Button in System Properties Wizard
  4. There are two ways to set path variable. You can set path for your account like username of your computer or set path variable for the System. To set both the paths , Click on Path> Edit as marked below in picture.
    Click on  Edit  to add new Path in Environment variable Path
  5. Now find the location of java in your computer. Go to C Drive > Program File >Java >Jdk >bin as shown below:-find location of jdk/bin  in computer
  6. Now  bin is open Right Click on any file > Properties ,Copy the marked path.
    copy location path of jdk/bin  in computer
  7. Now Go to Environment Variable Wizard & Click on New then Paste the path in Environment Variable path  that you copied in  previous step.
    Click on New to add new Path and paste the copied path
  8. Click Ok.
Great!   After this you can check in Command Prompt by again using javac command.
check javac in command prompt using javac command

javac run successfully, &  Cmd displays the details of javac command. It gave green indication that you can start coding in java, Next we will learn to write programs in java. Stay tuned!



Comments