javac 版本和 java 版本在命令行上显示不同 [英] javac version and java version show different on command line

查看:31
本文介绍了javac 版本和 java 版本在命令行上显示不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前,我有 java 8.我最近安装了 java 11.我将路径 Javajdk-11.0.7in 移到了环境变量的顶部.当我执行 javac -version 时,它给我版本 11.但是当我执行 java -version 时,它给我版本 8.我该如何解决这个问题?具体来说,我想运行一个使用 java 11 编译的 jar 文件.

Before, I had java 8. I recently installed java 11. I moved my path Javajdk-11.0.7in to the top of my environment variables. When I do javac -version it gives me version 11. But when I do java -version, it gives me version 8. How do I correct this? Specifically, I want to run a jar file that was compiled using java 11.

推荐答案

每当您安装 JDK 时,它也会询问 JRE 的路径.您可能提到了与 JAVA_HOME 不同的 JRE 路径或选择退出安装.如果发生这种情况,您应该卸载 Java 8 和 Java 11,然后再次安装 Java 11.但是,在执行此操作之前,您可以尝试/确保以下事项:

Whenever you install JDK, it asks for the path of JRE as well. There is a possibility that you mentioned a different path for JRE than the JAVA_HOME or opted out the installation. If that happened, you should uninstall both, Java 8 and Java 11 and then install Java 11 again. However, before you do this, you can try/ensure the following things:

  1. 如果你把PATH设置为%JAVA_HOME%in,如果安装路径(即JAVA_HOME的路径)将不起作用代码>) 有空格.在这种情况下,您需要将绝对路径而不是 %JAVA_HOME%in 放在 PATH 环境变量中.
  2. 在新的 cmd 窗口中尝试这些命令.
  3. 重新启动系统.
  4. 将 JDK bin 的路径移到用户变量和系统变量中的顶部.
  1. If you have put the PATH as %JAVA_HOME%in, it won't work if the installation path (i.e. the path of JAVA_HOME) has space. In such a case, you need to put the absolute path instead of %JAVA_HOME%in in the PATH environment variable.
  2. Try the commands in a new cmd window.
  3. Restart the system.
  4. Move the path of JDK bin to the top in both, User variables as well as System variables.

这篇关于javac 版本和 java 版本在命令行上显示不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆