简体   繁体   English

JDK 8在类路径中不可用

[英]JDK 8 not available in classpath

I have Java 7 in my machine from a long time .And now I have installed Java 8 too .The problem is even after changing the JAVA_HOME & path variable to point to jdk 8, I still get jdk 7 in the classpath. 很长时间以来我的机器上都装有Java7。现在我也安装了Java8。即使将JAVA_HOME和path变量更改为指向jdk 8,问题仍然存在,但我仍然在类路径中获得jdk 7。

Snapshot of the environment variables below 以下环境变量的快照

But I get the below when checking the version in windows.Is there anything else I should do to get it pointed to jdk8? 但是当我在Windows中检查版本时得到以下提示,是否还有其他方法可以让它指向jdk8?

C:\Users>java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Snapshot of the environment variables below 以下环境变量的快照

在此处输入图片说明

  1. Remove java.exe, Javac.exe and javaw.exe from system32 从System32移除java.exe, Javac.exe and javaw.exe
  2. Remove oraclePath like some text in path of system variable(from jdk8 it will create a new system variable when installing) 删除oraclePath类的系统变量路径中的文本(从jdk8安装时会创建一个新的系统变量)

Four things that come to mind: 我想到四件事:

  1. You seem to have edited the user variables. 您似乎已经编辑了用户变量。 Have you looked at the system variables? 您是否看过系统变量? I would prefer to set the JAVA_HOME and PATH variables at system level. 我希望在系统级别设置JAVA_HOMEPATH变量。
  2. Have you restarted cmd/Windows? 您重新启动了cmd / Windows吗?
  3. You could type where java in your cmd to see where Windows finds Java(s). 您可以在cmd中键入where java ,以查看Windows在何处找到Java。
  4. What is your PATH variable? 您的PATH变量是什么? Looking at your snapshot I it to contain at least %JAVA_HOME%\\bin . 查看您的快照,它至少包含%JAVA_HOME%\\bin

Can you check in your System variables that in the PATH variable, there is no path to your JDK 7? 您是否可以在System变量中检查PATH变量中是否没有JDK 7的路径?

Even if you define or override a Path variable in the "user" variables, Windows just concatenate the system variables with the user ones, in this order. 即使您在“用户”变量中定义或覆盖Path变量,Windows也会按此顺序将系统变量与用户变量连接在一起。

So if there is a path to your JDK 7 in System path, you will have this kind of value : PATH=;.....;D:\\java\\jdk8;%MAVEN_HOME% 因此,如果在系统路径中有指向您的JDK 7的路径,则将具有以下类型的值:PATH =; .....; D:\\ java \\ jdk8;%MAVEN_HOME%

Go in control panel and type java in the search box type java. 进入控制面板,然后在搜索框中键入java。 Click on the link on the java label. 单击Java标签上的链接。 Then click on tab java. 然后单击选项卡上的Java。 You will see the active runtimes. 您将看到活动的运行时。 Untick the one you don't need. 取消选中不需要的那个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM