I got a new laptop with windows 10
and I want to set it up so I can use java
and javac
from the command line.
I have searched online but all the guides are for previous versions, and I don't want to mess around with something I don't understand.
Just set the path variable to JDK bin in environment variables.
Variable Name : PATH
Variable Value : C:\Program Files\Java\jdk1.8.0_31\bin
But the best practice is to set JAVA_HOME and PATH as follow.
Variable Name : JAVA_HOME
Variable Value : C:\Program Files\Java\jdk1.8.0_31
Variable Name : PATH
Variable Value : %JAVA_HOME%\bin
To find the env vars dialog in Windows 10:
Right Click Start
>> Click Control Panel (Or you may have System in the list)
>> Click System
>> Click Advanced system settings
>> Go to the Advanced Tab
>> Click the "Environment Variables..." button at the bottom of that dialog page.
Here are the typical steps to set JAVA_HOME on Windows 10.
- Search for Advanced System Settings in your windows Search box. Click on Advanced System Settings.
- Click on Environment variables button: Environment Variables popup will open.
- Goto system variables session, and click on New button to create new variable (HOME_PATH), then New System Variables popup will open.
- Give Variable Name: JAVA_HOME, and Variable value : Your Java SDK home path. Ex: C:\Profram files\java\jdk1.8.0_151 Note: It should not include \bin. Then click on OK button.
- Now you are able to see your JAVA_HOME in system variables list.
- Select Path (from system variables list) and click on Edit button, A new pop will opens (Edit Environment Variables). It was introduced in windows 10.
- Click on New button and give %JAVA_HOME%\bin at highlighted field and click Ok button.
You can find complete tutorials on my blog :
How to set JAVA_HOME in 64 bit Windows 10 OS
Its still the same concept, you'll need to setup path variable so that windows is aware of the java executable and u can run it from command prompt conveniently
Details from the java's own page: https://java.com/en/download/help/path.xml
That article applies to: •Platform(s): Solaris SPARC, Solaris x86, Red Hat Linux, SUSE Linux, Windows 8, Windows 7, Vista, Windows XP, Windows 10