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 al
Adding Environment Variable simplified with screenshot. Check the below URL and you should be able to do without any trouble.
https://itsforlavanya.blogspot.com/2020/08/environment-variable-simple-7-steps-to.html
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.
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
if you have any version problems (javac -version=15.0.1, java -version=1.8.0)
then delete these in your system variable path
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\Program Files\Common Files\Oracle\Java\javapath
then if you're using java 15
path = C:\Program Files\Java\jdk-15.0.1\bin
is enough
if you're using java 8
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_271
path = %JAVA_HOME%\bin