1

So I'm trying to get the latest version of Java. When I run:

java -version

I get:

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

When I run:

javac -version

I get:

javac 1.6.0_65

Now I've just downloaded and installed JDK 8. When I go into System Preferences --> Java --> Update, I see:

Your system has the recommended vesion of Java.
Java 8 Update 05.

I guess I have a few questions:

1) Don't I want the JDK and my version of Java to match up?

2) Why does my Java Control Panel claim I have Java 8, but my work in the terminal (when checking my Java version) says otherwise?

Thanks for the help, Mariogs

asked Apr 23, 2014 at 20:09
3
  • Have you tried restarting your computer? Commented Apr 23, 2014 at 20:15
  • 2
    Does your PATH system variable contain the directory where jdk 1.6 is installed? Commented Apr 23, 2014 at 20:15
  • 1
    This might be a question that is better suited to SuperUser, as you don't indicate the OS it is impossible to answer. In for example Windows it can depend on the PATH, on some (all?) Linux distribution you can configure the preferred Java which is then bound to the java command, etc. Commented Apr 23, 2014 at 20:15

5 Answers 5

4

The probably "simple" answer is you have two versions of java installed. On the command line you currently use 1.6. Thus the old one is active. In system preferences you see the version of java 8.

Windows: You can change the version of the command line to java 8. Set PATH environment variable and JAVA_HOME or via windows preferences. I recommend the first one.

Mac: /usr/libexec/java_home is the starting point for switching java versions on the command line. Check out this post to understand how to handle different java versions on the Mac. IMHO this answer is a good solution.

answered Apr 23, 2014 at 20:15
Sign up to request clarification or add additional context in comments.

Comments

4

The Java Platform offers both the JRE and the JDK in order for users to run Java programs. The JRE stands for the Java Runtime Environment, and the JDK stands for the Java Development Kit.

The JDK is meant for Java developers - that is, those who build applications/write programs in Java. It contains tools that are needed for Java coding, including -javac to compile programs.

The JRE is meant for regular users - those who only need to run Java programs on their computer and are not interested in development.

The reason for the discrepancy in your case is because you're looking at the JRE and JDK and trying to compare the two. The current JDK that you have is Java 8, whereas the current JRE that you have is 1.6.0_65. It is problematic that your JRE version does not match your JDK version, but without your PATH variable or other information about your install, we can't help you fix your installation.

answered Apr 23, 2014 at 20:15

1 Comment

Ah, so I'm on a Mac (OS X 10.9.2)
2

1) Yes, if you use the JDK at all, you want the JRE (runtime environment) to come from the JDK (development environment) (a JDK necessarily includes a JRE).

2) Likely your path variable is set so that you invoke Java from your Java 6 installation; you need to find the equivalent for your Java 8 installation and set the path for that. Without information about your operating system, we can't help you do that.

answered Apr 23, 2014 at 20:16

2 Comments

Am on Mac OS X 10.9.2. Thanks again!
On StackOverflow, you should accept the earliest answer that answered your question, and upvote any that you found helpful. It's the way people gather reputation on the site, and also helps people know that you will do so on other questions.
1

We should know the reason for this

  1. Our OS comes with a predefined (built-in)set of tools and utilities. When we try to execute the command e.g. cls in the Windows command line then it is already present in system path variable and os will refer the corresponding binary of cls to execute the command.

  2. However, when we install any third party tool/software then path variable is not updated accordingly.

  3. When we install different versions of java on your system then installations go to different directories. E.g. JDK installation directory for Windows will be C:\Program Files\Java\jdk1.8.0_161

  4. Similarly, JRE installation directory for Windows will be JDK installation directory for Windows will be C:\Program Files\Java\jre1.8.0_161

  5. We need to update the path variable of OS to point to the appropriate directory. If we set the path of JDK then it will execute a binary from JDK bin directory.

Solution

  • we need to update JDK or JRE version specific directory location into PATH Environment variable.
answered Jul 26, 2018 at 9:40

Comments

0

Let me see if I can clear it up for you.

1)Yes, arguably you nearly want this to be true.

2)It could be few things, but most likely that a previous instillation was not properly removed. So one gets called instead of the other.

answered Apr 23, 2014 at 20:23

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.