0

Just installed java 1.7 update 51 on a Windows 7 machine. AFAICT, when I compile a source, the system automatically uses the new java. But I try to run it, the system automatically tried to run it with an old java 1.6, and the newly compiled code won't run. How do I convince the machine to use only the 1.7 distribution?

5
  • 4
    fix your paths ahd classpaths Commented Feb 1, 2014 at 18:43
  • 2
    Uninstall the 1.6 runtime. Commented Feb 1, 2014 at 18:43
  • 4
    Change your PATH and JAVA_HOME environment variables to point to the 1.7 installation if you want to keep the 1.6. Commented Feb 1, 2014 at 18:45
  • Or set the target to 1.6 while compiling stackoverflow.com/questions/15492948/… Commented Feb 1, 2014 at 18:49
  • I confirmed that there's no reason to keep the 1.6 (and I understand old java versions present security issues anyway) so I just uninstalled the 11.6 and now everything is fine. Thanks! Commented Feb 1, 2014 at 18:59

2 Answers 2

1

Do you have java.exe in your System32 folder?
I suspect this might be your problem.
See this question I recently asked.

Java Windows7 System32 folder java.exe

I suggest you remove both JDKs, then you install them both without the
option to install a public JRE (be careful about this at installation time).

Also, make sure you understand/control what is in your PATH variable.

I also have both 6 and 7 on my machine, and
since I got rid of the public JREs I am fine.

Sign up to request clarification or add additional context in comments.

Comments

1

There is a difference between the JDK (java development kit with javac compiler), and the JRE (java runtime environment). Simply doing an additional JRE 7 installation will do. (This might have been asked during the installation of the JDK.)

1 Comment

As I am generally running Linux, consider @peterpetrov first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.