Mac OS X 용 Java JDK 7을 설치 한 후-mvn -version에 여전히 Java 버전 1.6.0_31이 표시됩니다
Oracle은 4 월 26 일 Mac OS X 용 Java JDK 7을 릴리스했습니다. 설치 지침을 따르고 터미널 창에서 java -version을 수행하면 다음과 같은 결과가 나타납니다.
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)
그러나 mvn -version
터미널 창에서 할 때 나는 다음 을 얻습니다.
Apache Maven 3.0.2 (r1056850; 2011-01-08 18:58:10-0600)
Java version: 1.6.0_31, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.7.3", arch: "x86_64", family: "mac"
Maven에서 Java JDK 1.7.0_04를 사용하려면 어떻게해야합니까?
도와 주셔서 감사합니다.
마침내 여기에서 답을 찾았습니다
http://www.adam-bien.com/roller/abien/entry/java_se_development_kit_7
JAVA_HOME=$(/usr/libexec/java_home)
Mac에서 대신 사용 하고 "Java Preferences.app"를 통해 현재 jdk를 설정해야합니다.
~ / .profile에서 JAVA_HOME을 설정하십시오.
문제는 JavaVm.framework 버전의 기호 링크 "CurrentJDK"가 이전 jdk를 가리 키므로 CurrentJDK를 최신 버전 (1.7.0_45)으로 설정하기 위해 다음 명령을 사용할 때 작동합니다.
cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents CurrentJDK
참조 : http://java.dzone.com/articles/installing-jdk-7-mac-os-x
Java 환경 설정에서 경로를 찾으려면 /usr/libexec/java_home -X
내 Java7 항목은 다음과 같습니다.
<dict>
<key>JVMArch</key>
<string>x86_64</string>
<key>JVMBundleID</key>
<string>com.oracle.java.7u04.jdk</string>
<key>JVMEnabled</key>
<true/>
<key>JVMHomePath</key>
<string>/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home</string>
<key>JVMIsBuiltIn</key>
<false/>
<key>JVMName</key>
<string>Java SE 7</string>
<key>JVMPlatformVersion</key>
<string>1.7</string>
<key>JVMVendor</key>
<string>Oracle Corporation</string>
<key>JVMVersion</key>
<string>1.7.0_04</string>
</dict>
JAVA_HOME
환경 변수를 새 JDK 1.7 위치 로 변경해야합니다 .
JAVA_HOME이 정의 될 수있는 가능한 위치에 대해서는 이 질문 을 보십시오 . 터미널에서 입력 which java
하여 Java 설치 경로를 찾은 다음 JAVA_HOME
해당 경로를 가리 키도록 업데이트하십시오 (그러나 마지막 bin 폴더는 제외).
누구나 Mac OSX 'Mavericks'를 실행하는 64 비트 Mac에 Maven을 설치하는 경우 시간을 절약하고 Maven을 설치하려고하는 일부 머리카락을 절약 할 수 있습니다. Mavericks에서 java_home의 위치가 변경되어 실패했기 때문에 이것을 따르려고했습니다.
http://maven.apache.org/download.cgi
I was pulling my hair out until I found this website, which recommends you Install homebrew and follow the instructions on this page: http://techspunky.blogspot.in/2013/10/how-to-install-maven-on-mac-osx-109.html
once complete don't panic when $ maven -version doesn't work, instead use $mvn --version as maven.apache.org/download.cgi recommended.
It worked, but then I noticed the Java SDK Maven was using was Java version: 1.6.0_65, which is not the latest SDK I installed on the system.
Once I set the JAVA_HOME=/usr/libexec/java_home
It was using the correct SDK: Maven home: /usr/local/Cellar/maven/3.1.1/libexec Java version: 1.7.0_45, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
Success! but wait... next time I opened the terminal and ran mvn -v it went back to java version 1.6. WTH!
its some sort of supposed bug from what I read use: echo JAVA_HOME=/usr/libexec/java_home -v 1.7
| sudo tee -a /etc/mavenrc
and now:
Maven home: /usr/local/Cellar/maven/3.1.1/libexec Java version: 1.7.0_45, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
The reason Maven is still using Java 6 is that the /usr/bin/mvn script that launches it does not use the correct OS/X method for resolving the current Java version as specified in Java Preferences. See this Maven issue for details:
http://jira.codehaus.org/browse/MNG-4226
Voting it up might get it fixed; in the meantime, if you alter the /usr/bin/mvn script as shown in the comments & patch on that issue you will get the desired result.
Ok on my machine. Yes, the Oracle installer didn't exactly do its job, and it confused me to no end after 1.6 was still running.
java run time was updated
java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
but the SDK HOME is actually a sim link still pointing to 1.6
/Library/Java/Home
in finder GetInfo points to /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
in Terminal
./Home -> /System/Library/Frameworks/JavaVM.framework/Home
Go figure.
I found 1.7 here and I'm using that to build with: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
I think the problem lies partly with the java launch mechanism. I have been able to get Eclipse to run my code under Java7, but I think eclipse itself is still running under Java6. Also, I have a java program that was last compiled a year ago, and built using jarbundler-2.1.0.jar (with option jvmversion="1.6+"). When I double click the .app file it runs Java6, but when I double click the .jar file inside the .app it runs Java7.
Also, I do not use JAVA_HOME, but I still get the correct java version "1.7.0_04" shown in the question. JAVA_HOME seems to be a red herring. Maybe Maven needs it, but Eclipse doesn't seem to use it, and neither does launching jar files.
And after setting Java7 in the Java Preferences tool, it does not seem to affect launching .app java files. However it does make 'java -version' from the terminal work nicely. I tried unchecking everything but the Java7 option, and then Eclipse wouldn't run at all.
If your JAVA_HOME is located at the local user's bash, mvn will pick the system's current java version no matter what JAVA_HOME you've set.
Hence first run the command 'which mvn' and check which executable mvn you are using. After that edit that mvn file and change the JAVA_HOME variable to your prefered java home.
'development' 카테고리의 다른 글
Windows Forms 응용 프로그램의 예외 처리에 대한 모범 사례? (0) | 2020.07.19 |
---|---|
console.log ()와 console.debug ()의 차이점은 무엇입니까? (0) | 2020.07.19 |
PostgreSQL 데이터베이스에서 어떤 타임 스탬프 유형을 선택해야합니까? (0) | 2020.07.19 |
Java 문자열 형식을 사용하여 정수 형식화 (0) | 2020.07.18 |
디버그 로그를 인쇄하는 방법? (0) | 2020.07.18 |