Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java path set wrongly

I have installed Java on a new system. Some random path in my C drive is automatically set for my PATH variable. Whenever I try to run Java, it shows java.exe not found in that wrong path!

I'm trying to change the PATH variable using the SET command, but the new path is only getting added along with the old one. I could not run Java on the system.

set PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_71\bin 

I've tried setting PATH variable in Windows Environment Variables list also after setting JAVA_HOME!

When I type Java in cmd, i get:

The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe.

This path is the old unknown automatically set path.

Is there any way to run Java! I'm using windows 8.

like image 464
user3387219 Avatar asked Nov 22 '14 18:11

user3387219


2 Answers

if you are using windows system, please create java_home as a variable and set java home path i.e. till C:\Program Files\Java\jdk1.7.0_71, and in path variable do not delete existing just append new with ;%java_home%\bin

this will work

in you case SET is valid till command prompt is open. do the above changes in my computer -> properties -> advanced ->environment variables

like image 135
prsutar Avatar answered Oct 08 '22 00:10

prsutar


I know this post id very old. I faced this issue recently. Please follow the following steps to resolve your issue:

  1. Search for "Regedit" in "start menu".
  2. Once found, right-click it and choose "run as Administrator" option.
  3. Enter your administrator credentials and Enter.
  4. Go to "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7"
  5. Double-click on "JavaHome" name and change its value to "C:\Program Files\Java\jdk1.7.0_71".
  6. Close all your command prompts and open a new Command prompt and it should reflect.
like image 34
user2767222 Avatar answered Oct 07 '22 23:10

user2767222