your programing

Windows는 JAVA_HOME을 무시합니다. JDK를 기본값으로 설정하는 방법은 무엇입니까?

lovepro 2020. 10. 11. 11:04
반응형

Windows는 JAVA_HOME을 무시합니다. JDK를 기본값으로 설정하는 방법은 무엇입니까?


Windows에서 JRE 대신 JDK를 사용하도록 어떻게 설득합니까?

이 질문은 이전, 여기 및 다른 곳에서 요청되었습니다.

기본 Java 설치 / 런타임 (Windows)을 어떻게 설정합니까?

문제는 Windows가 무시 JAVA_HOME하고 JDK bin 디렉토리를 경로의 첫 번째 항목으로 만든 사실도 무시한다는 것입니다.

java -version명령 줄에서 실행할 때 JDK 1.6 설치를 호출하는 대신 1.7 JRE를 실행합니다.

내 생각 엔 이것이 1.7에만 해당하는 문제이고 Windows 7은 레지스트리에서하지 말아야 할 일을하고 있다는 것입니다.

이 문제를 해결하는 방법에 대한 아이디어가 있습니까?

편집 : 죄송합니다. "경로"를 의미했을 때 위의 "클래스 경로의 첫 번째 항목"을 썼습니다. 죄송합니다.


Windows에서 java실행 파일은 Windows 레지스트리를 사용하여 실행할 Java의 기본 버전을 찾습니다.

java.exe실행할 사본은 PATH환경 변수 를 사용하여 찾을 수 있습니다. 이를 변경하는 단계를 수행하지 않는 한 기본적으로 Windows 디렉토리에 사본이 있습니다. 이 복사본은 Java 런타임 디렉터리에 없기 때문에 레지스트리를 확인하여 찾습니다.

그래서, 당신도 필요 레지스트리를 수정, 또는 당신이 원하는 자바의 버전을 넣어 전에 당신의 Windows 디렉터리 PATH.


Windows 8에서는 C:\ProgramData\Oracle\Java\javapath디렉터리 를 제거 할 수 있습니다 .

경로에서

내 문제가 해결되었습니다.


나도이 문제가 있습니다. 1.6을 실행 중이지만 1.5로 작업중인 코드를 빌드하고 싶습니다. 나는 변경했습니다 JAVA_HOMEPATH아무 소용 (사용자 모두 및 시스템).

대답은 1.6의 설치가 하락한다는 것입니다 java.exe, javaw.exe그리고 javaws.exe내에 Windows\System32폴더 (윈도우 7).

나는 이러한 파일 이름을 변경하여 그것을 해결 java_wrong.exe, javaw_wrong.exe하고 javaws_wrong.exe. 그렇게 한 후에 만 JAVA_HOME및에 정의 된 올바른 Java 버전을 선택합니다 PATH. 쉽게 되돌릴 수있는 방식으로 파일을 삭제했기 때문에 파일 이름을 변경했습니다.

도움이 되었기를 바랍니다!


Windows는 아무것도 무시하지 않습니다. 이것은 설정 문제입니다. Windows는 귀하가 제공하는 것만 사용합니다. 에 대한 특별한 지식이 없습니다 JAVA_HOME.

CLASSPATHWindows 와도 관련이 없습니다. Windows에서는 폴더 위치로 확장되는 유일한 환경 변수입니다.

%PATH%환경 변수를 확인하십시오 . Windows가 다른 하나를 먼저 찾는 이유입니다. 경로 (링크 한 게시물)는를 가리켜 야합니다 %JAVA_HOME%\bin;<remainder of path>. 다시 말하지만, 링크 한 게시물은 배치 파일을 사용하여이를 설정하는 방법을 제공했습니다.

(이것을 모르는 다른 사용자를 위해 : % PATH %를 검사하는 가장 쉬운 방법은 명령 프롬프트를 열고를 입력하는 것 echo %PATH%입니다. Computer시작 메뉴의 오른쪽 창에서 를 마우스 오른쪽 버튼으로 클릭 하고을 선택한 Properties다음 Advanced System Settings, 및 tne Environmental Variables버튼.)


나는 같은 문제가 있었다. Java 버전이 많이 설치되어 있으며 어떤 이유로 1.6 (C : \ jdk1.6.0_45_32 \ bin)을 사용하도록 경로를 지정했지만 Java 1.6 대신 Java 1.7이 사용되었습니다.

Windows가 1.7 대신 1.6을 사용하도록 PATH 환경 변수의 첫 번째 항목이되도록 (1.6)을 사용하려는 JDK의 경로를 이동해야했습니다.

예를 들어 이전의 PATH 환경 변수는 다음과 같습니다.

C:\Program Files (x86);...<other entries>;C:\dev\ant181\bin;C:\jdk1.6.0_45_32\bin

jdk를 첫 번째로 옮긴 후 작동했습니다.

C:\jdk1.6.0_45_32\bin;C:\Program Files (x86);...<other entries>;C:\dev\ant181\bin

Java 1.7의 Windows 설치 프로그램이 이미 PATH에있는 다른 디렉터리에 설치 했으므로 지정된 사용자 지정 PATH 항목 C : \ jdk1.6.0_45_32 \ bin 대신 먼저 사용됩니다.


'Path'변수의 내 사례 에는 ' C:\ProgramData\Oracle\Java\javapath;' 와 같은 매개 변수가 추가되었습니다 . 이 위치에는 java.exe, javaw.exeOracle을 javaws.exe통해 새로 설치된 Java 8이 jdk.exe있습니다.

내 경로가 이미 가지고 %JAVA_HOME%\bin있는 경로에서이 텍스트를 제거 했습니다.

이제 변수 'JAVA_HOME'가 내가 원하는 Java 버전을 제어하고 있습니다.


Java 7 및 8이 설치되어 있고 Java 7로 리디렉션하고 싶지만 cmd 프롬프트 창에 Java 버전이 Java 8로 표시됩니다.
Java 7 bin 디렉터리 경로 ( C : \ Program Files \ Java \ jdk1.7.0_10 \ bin )가 추가되었습니다. 끝에서 PATH 변수로 변경했지만 작동하지 않고 Java 8을 보여줍니다. 그래서 Java 7 경로를 경로 값의 시작으로 변경하고 작동했습니다.
새 cmd 프롬프트 창을 열고 Java 버전을 확인했는데 이제 Java 7이 표시됩니다.


여기에 이미지 설명 입력JDK 8 이후에 JDK 10을 설치하고 시스템 환경 변수에 "C : \ ProgramData \ Oracle \ Java \ javapath"와 같은 경로를 설정 한 다음이 경로로 Java 버전을 제어한다고 가정합니다. 여기에 jdk 1.8 경로가 설정되어 있어도 JAVA_HOME을 무시하므로 JAVA_HOME 경로의 효과를 얻으려면 경로에서 "C : \ ProgramData \ Oracle \ Java \ javapath"를 제거하십시오.


Set Path environment variable to your desired jdk/bin directory


In my case I had Java 7 and 8 (both x64) installed and I want to redirect to java 7 but everything is set to use Java 8. Java uses the PATH environment variable:

C:\ProgramData\Oracle\Java\javapath

as the first option to look for its folder runtime (is a hidden folder). This path contains 3 symlinks that can't be edited.

In my pc, the PATH environment variable looks like this:

C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Program Files\Java\jdk1.7.0_21\bin;

In my case, It should look like this:

C:\Windows\System32;C:\Program Files\Java\jdk1.7.0_21\bin;

I had to cut and paste the symlinks to somewhere else so java can't find them, and I can restore them later.

After setting the JAVA_HOME and JRE_HOME environment variables to the desired java folders' runtimes (in my case it is Java 7), the command java -version should show your desired java runtime. I remark there's no need to mess with the registry.

Tested on Win7 x64.


There's an additional factor here; in addition to the java executables that the java installation puts wherever you ask it to put them, on windows, the java installer also puts copies of some of those executables in your windows system32 directory, so you will likely be using which every java executable was installed most recently.


Just in case if you are using .BAT file as Windows Service, I would suggest to uninstall the Windows service and reinstall it again after changing the %JAVA_HOME% to point to the right Java version..


This issue is probably because of the earlier versions of Java installed in your System. First check your Environment Variables Carefully and remove all the Environment Variables related to the previous versions of JAVA and replace those paths to

C:\Program Files\Java\<your new jdk version>\bin

After struggling with this issue for some time and researching about it, I finally managed to solve it following these steps:

1) install jdk version 12
2) Create new variable in systems variable
3) Name it as JAVA_HOME and give jdk installation path
4) add this variable in path and move it to top.
5) go to C:\Program Files (86)\Common Files\Oracle\Java\javapath and replace java.exe and javaw.exe with the corresponding files with the same names from the pathtojavajdk/bin folder

마지막으로 "java -version"을 사용하여 cmd에서 java의 기본 버전을 확인했고 작동했습니다!

참고 URL : https://stackoverflow.com/questions/5492937/windows-ignores-java-home-how-to-set-jdk-as-default

반응형