How to set path for Jre 6 when jre 7 installed?

前端 未结 12 788
深忆病人
深忆病人 2021-01-18 00:19

I am programming through java 1.6 u_17, but i have JRE version 6 and JRE version 7 installed, so how to run my compiled program from JDK 1.6 to run through the JRE 6 only?<

相关标签:
12条回答
  • 2021-01-18 00:47

    java.exe is also available in C:\windows\system32 and in your case its version might be 1.7..

    Since your path has C:\windows\system32 first. no matter how to set rest of the path, sonar always will load jre7. (refer to conf\wrapper.conf in Sonar directory, by default it has wrapper.java.command=java)

    To fix this, change following property of the "wrapper.conf" file wrapper.java.command=C:\Program Files\Java\jdk1.6.0_XX\bin\java

    this will fix the issue irrespective of the path variables.

    0 讨论(0)
  • 2021-01-18 00:53

    Windows is checking the PATH variable to find an executable named java and using that to launch your application. It is quite normal in a development environment to have many installations (as you do). However this calls on you to manage your environment.

    There are two ways for you to set environment variables in Windows. By going to My Computer > Advanced Settings > Environment Variables as described above, you can set a variabler to your JDK installation and then update the Path to find the bin directory in that installation. Youy have the choice of updating System variables (all users) or user variables (your account only).

    Personally, I prefer not to use the system/user environment variables as this provides less flexibility. You can use bat files to explicitly set the Path for a specific moment in time, or indeed to override the JAVA_HOME to point to a different installation.

    If you are using an IDE you can usually specify the target runtime on a per project basis. Alternatively, when running the program, provide the fully qualified path to the version of the java executable you wish to use.

    0 讨论(0)
  • Background

    I'm using Windows 8.1 and I have both JDK6 and JDK8 installed. For development purpose, I needed to get java version "1.6.0_45" over the command java -version and javac 1.6.0_45 over javac -version. The second command was working as expected after setting JAVA_HOME as Home folder of JDK6 and adding %JAVA_HOME/bin% in Path. However the first command was still returning java version "1.8.0_71"

    Troubleshooting

    I could find the an entry in the Path environment variable which points to C:\ProgramData\Oracle\Java. This folder actually contains short cut to java.exe of JDK8.

    Proper solution: Uninstall JDK 8

    Workaround:Edit the short cut file so that it points towards java.exe inside %JAVA_HOME%\bin (Please replace the variable with actual folder)

    0 讨论(0)
  • 2021-01-18 00:56

    set the PATH variable to your jdk6\bin directory. so that it will pick the javac and java from jdk6.

    for setting the path variable go to Environment Variables. After setting the path variables you need to restart your command prompt. (NOT the computer).

    0 讨论(0)
  • 2021-01-18 01:00

    I had same problem. Issue is that Java installation will copy a java.exe, javaw.exe and javaws.exe to windows/system32 directory. You must have installed JDK7 recently.

    I just removed those files from Windows/System32 directory, however, kept older version in path. This solved the issue.

    Try it out.

    0 讨论(0)
  • 2021-01-18 01:00

    Just right click on MyComputer, then Advanced System Settings-->Environment Variables-->New Then in the "variable Name" text field add the string "PATH" or if it already exists select PATH from the list and click edit then append the path for "bin" folder in java in program files to the Variable value text field followed by a semicolon (;), if not exits add the path of bin directory of your java folder in "Variable Value" field and click "OK".

    If you want to check the result, open up a command prompt and type "java" then hit enter.

    0 讨论(0)
提交回复
热议问题