I recently downloaded Java SDK 8.0 on my computer running Windows 10. However, when I looked on the Internet for how to use Java in the Windows 10 Command Prompt, I was only able to get the javac
command to work in the prompt. When I tried to run my program, the command prompt said that it could not find the java.exe
file. Does anyone know how to make Java work in Windows 10? (I'm using the x86 version of Java.)
Asked
Active
Viewed 4.0k times
0

ButtonMasterBot
- 317
- 2
- 5
- 14
-
1Add the directory where `java.exe` is to the environment variable `path` – MadProgrammer Sep 03 '15 at 01:22
-
It's the same directory as the `javac.exe` file, and that one works. – ButtonMasterBot Sep 03 '15 at 01:23
-
You may have different version installed. Java on Windows can be installed into the Windows directory itself, which can mess things up, but I think that's the JRE. The JDK also installs the JRE – MadProgrammer Sep 03 '15 at 01:25
-
So the only files that are unrecognized are the programs with the Java icon next to them. Does this help at all? Also this is the directory path for `java.exe`: `C:\Program Files (x86)\Java\jdk1.8.0_60\bin` – ButtonMasterBot Sep 03 '15 at 01:29
-
Have you tried running the command console as admin or in compatibility mode. Can't say I've had any issues... – MadProgrammer Sep 03 '15 at 01:37
-
That doesn't change anything. – ButtonMasterBot Sep 03 '15 at 01:40
-
Have you tried to run it directly (qualified)? `"C:\Program Files (x86)\Java\jdk1.8.0_60\bin\java.exe" -version` – Andreas Sep 03 '15 at 01:52
-
It says this: `java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode, sharing)` – ButtonMasterBot Sep 03 '15 at 02:03
-
So Java is running fine, which means that if a plain `java -versions` doesn't work, your `PATH` is misconfigured. – Andreas Sep 03 '15 at 02:23
-
What is the exact error message (including path info)? Recent versions of Java add `C:\ProgramData\Oracle\Java\javapath` to the path and then the exes in `javapath` are actually symlinks to the real exes. Maybe the links are messed up. – prunge Sep 03 '15 at 03:19
-
The error says: "The system cannot find the file C;\ProgramData\Oracle\Java\javapath\java.exe" – ButtonMasterBot Sep 03 '15 at 03:31
-
1Sounds like symbolic link problem. [This question and answer](https://stackoverflow.com/a/27572837/523391) might help. – prunge Sep 03 '15 at 03:39
-
possible duplicate of [How to solve the error: The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe](http://stackoverflow.com/questions/26864662/how-to-solve-the-error-the-system-cannot-find-the-file-c-programdata-oracle-ja) – prunge Sep 03 '15 at 03:40
2 Answers
1
Java doesn't actually have to be installed. You can run any Java that's available to you.
This is sometimes useful for running Java from a network share.
Try running the java.exe
program by fully qualifying it. If it runs that way, your problem is with your PATH
.
To illustrate that you can run any Java by qualifing it, I have 9 JDK's and 1 JRE installed:
- 32-bit JDK: Versions 1.4, 5, 6, 7, and 8
- 64-bit JDK: Versions 5, 6, 7, and 8
- 32-bit JRE: Version 8
Copied from a single command prompt window:
C:\>"C:\prog\java32\jdk1.4.2_19\bin\java.exe" -version
java version "1.4.2_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)
Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)
C:\>"C:\prog\java32\jdk1.5.0_22\bin\java.exe" -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode)
C:\>"C:\prog\java32\jdk1.6.0_45\bin\java.exe" -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)
C:\>"C:\prog\java32\jdk1.7.0_79\bin\java.exe" -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode, sharing)
C:\>"C:\prog\java32\jdk1.8.0_51\bin\java.exe" -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode)
C:\>"C:\prog\java64\jdk1.5.0_22\bin\java.exe" -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
C:\>"C:\prog\java64\jdk1.6.0_45\bin\java.exe" -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
C:\>"C:\prog\java64\jdk1.7.0_79\bin\java.exe" -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
C:\>"C:\prog\java64\jdk1.8.0_51\bin\java.exe" -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
C:\>"C:\Program Files (x86)\Java\jre1.8.0_51\bin\java.exe" -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode, sharing)

Andreas
- 154,647
- 11
- 152
- 247
1
Open command prompt cmd
and type where java
, this will output where java executable is, then you can go to System Propreties>Advanced>Environement Variables>
(Right click on computer and click on Propreties)
and add the where java
output to the PATH
variable separated with a semi-colon ;

moolsbytheway
- 1,152
- 13
- 20