Setting up enviromental variables in Windows 10 to use java and javac
Solution 1
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
Solution 2
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:\Program 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. (If you are not able to, try doing it again.)
- 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 :
Solution 3
- Right click Computer
- Click the properties
- On the left pane select Advanced System Settings
- Select Environment Variables
- Under the System Variables, Select PATH and click edit,
and then click new and add path as C:\Program
Files\Java\jdk1.8.0_131\bin (depending on your installation path)
and finally click ok - Next restart your command prompt and open it and try javac
Solution 4
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.
Solution 5
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
Related videos on Youtube
kilmarta
Updated on July 09, 2022Comments
-
kilmarta almost 2 years
I got a new laptop with Windows 10 and I want to set it up so I can use
java
andjavac
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.
-
kilmarta over 8 yearswhile it says at the top that it applies to win 10, there is no section for win 10. Is it the same as win 8?
-
whitecoffee over 8 yearsTry and see if you can find the similar things in windows 10 corresponding to windows 8 that u see in the link. The underlying concept hadn't change set path to tell windows where to look at to run your commands that u dont want to have to type out the full directory of that command
-
Ahmet about 8 yearsDo not forget to restart the terminal, i.e. the "cmd", (not the computer) through which you checked the "java -version" or wanting to run any other program using CLI
-
johnrubythecat about 8 yearsSince the Java folder doesn't exist on a new Windows10 installation, that is a misleading and worse than useless response.
-
worc over 6 years@johnrubythecat a java 8 / windows 10 setup can be done with a jdk directory tree like what's used in this answer.
-
theINtoy over 2 yearsJust to update my orignal answer. I have found RapidEE to be a much better way of editing/maintaining env vars in windows: rapidee.com/en/about
-
Śhāhēēd about 2 yearsBefore I wasn't aware about this! Always leave it as it's! After a good lesson right now I'm too much aware about this! What's a silly things made me mad! It's a awesome solution & save the day. Thank you tharsikan