3

My Windows 8 command prompt doesn't see java anymore. I found that in C:\ProgramData\Oracle\Java\javapath located wrong symlink that I can't change. When I try change I got error:

Problem with Shortcut

The name 'C:\Program Files\Java\jre1.8.0_45\bin\javaw.exe' specified in the Target box is not valid. Make sure the path and file name are correct.

When I try to create shortcut I have message:

Windows can't create a shortcut here.
Do you want the shortcut to be placed on the desktop instead?
[Yes] [No]

How to solve this problem?

vico
  • 17,051
  • 45
  • 159
  • 315
  • Uninstalling and reinstalling the runtime is probably the safest way of restoring the correct symlinks if you aren't confident about fixing them by hand. – Harry Johnston Jul 20 '15 at 09:25

3 Answers3

17

Here is how you solve this problem :

  • Delete the original symlinks. All the three of them, I think there are three.
  • Do not create a shortcut. Shortcut and Symlinks are not same.
  • Open a command prompt in the same directory and create new Symlinks using the "mklink" command and point it to your JDK install.
Geek
  • 23,089
  • 20
  • 71
  • 85
  • 3
    Beware: If you have two different Java versions, you'll also have to change CurrentVersion key in HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment via regedit in cmd! – FranciscoBouza Jan 19 '17 at 18:36
7

If you use java from the command prompt chances are high that you need to have correct JAVA_HOME variable set as well. Some tools depend on it.

To do it - edit the system environment variables:

  1. Add JAVA_HOME and point it to the install path of java version you want you could also use symbolic link for the folder
  2. In "Path" variable find "C:\ProgramData\Oracle\Java\javapath;" and replace it with %JAVA_HOME%\bin
user3659594
  • 71
  • 1
  • 3
0

First Uninstall the java from your system, after remove the oracle folder in C:\ProgramData. Then again reinstall the java. Next click on javac.bat in bin folder of jdk.After check with command prompt like, >javac it will display all the options.then it's working perfectly...

I think it's duplicate of

How to make a symlink in Java when running in Linux?

Community
  • 1
  • 1