Different Java version showing on command line

前端 未结 4 1746
灰色年华
灰色年华 2021-02-07 07:31

I have recently checked on my Java version. I ran the command java -version and I found out that I was using java version 1.7.0_09. But when I tried to

4条回答
  •  礼貌的吻别
    2021-02-07 07:59

    In answer to the "actual" question:

    Another thing that is weird is, I tried to check on environment variable settings, and it does not say anything about jdk1.7.0_09.

    What happened here is that you installed jdk1.7.0_07 and then you auto-upgraded it. When that happens , it still uses the old folder name that you originally installed to.

    After I install Java , I usually make a copy of the JDK directory and name it with the version number. Then, I can directly call a certain java like so:

    @echo off
    :: testjava.bat
    set JAVA_HOME=C:\JDK1.x.xx
    set PATH=%JAVA_HOME%\bin;%PATH%;.
    java -version
    pause
    

    So, my recommendation is to set your JAVA_HOME system variable and PATH variable like I show above. This would override everything on your system so that your JDK of your choice is the default over the JRE.

提交回复
热议问题