Java - JDK Downgrade | Reverting 하기 (MacOS)

2022. 1. 30. 02:07Computer Science/Languages -

Introduction

자동화 스크립트를 PageFactory를 사용해 리팩토링해서 테스트를 돌려보니 아래와 같은 에러가 뜬다. 

java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy10.proxyClassLookup()

구글링을 해보니... JDK 16 이상에서 나오는 이슈라고 한다. 

ayuryev형이 자세히 설명을 해주었으나, 잘 이해는 되지 않는다...

 

아무튼, jdk를 16에서 15로 다운그레이드하면 문제가 해결된다고 하니, 다운그레이드 해야겠다! 라고 생각 했는데, 어떻게 하더라..?하고 다시 구글링을 해서... 환경변수만 바꿔주면 기존에 jdk를 지우지 않고도, 다운그레이드가 가능하다고 한다. 

 

How to revert JDK  version

 

1. 현재 jdk 버전을 확인

java -version

 

 

 

2. 필요한 jdk를 다운로드 @ https://jdk.java.net/archive/

 

Archived OpenJDK GA Releases

Archived OpenJDK General-Availability Releases This page is an archive of previously released builds of the JDK licensed under the GNU General Public License, version 2, with Classpath Exception. WARNING: These older versions of the JDK are provided to he

jdk.java.net

 

3. (Optional) jdk 파일 디렉토리로 옮겨주기. 

Downloads 디렉토리에 인스톨되서 jdk 디렉토리로 옮겨주었습니다 :) 

/Users/{User Name}/Library/Java/JavaVirtualMachines/{ 여기! }

 

 

4. 환경변수 설정

# List Java versions installed
# 맥에 설치되어있는 jdk를 터미널에 보여줍니다.
/usr/libexec/java_home -V

# List JAVA_HOME 환경변수
echo $JAVA_HOME


# 환경변수를 '영구적'으로 바꿔보겠습니다.
# 환경변수 경로를 bash_profile에 저장을 할겁니다.
#List bash_profile if already you have
cat .bash_profile

#만약에 bash_profile이 없으시다면, 만들어봅시다.
touch .bash_profile

# vim editor로 bash_profile을 열어줍니다.
vim .bash_profile
Press 'i'

# -v 뒤에 버전 넘버를 입력해 주면 해당 버전의 jdk로 환경변수가 설정됩니다.
export JAVA_HOME=$(/usr/libexec/java_home -v 15)

#수정된 경로를 저장해 줍시다.
Press 'esc'
:wq!
Enter

#업데이트 된 bash_profile을 실행시켜줍니다.
source ~/.bash_profile

 

5. java 버전 확인해서 다운그레이드 되었는 지 확인

java -version

 

Conclusion

언제쯤 configurations error에서 자유로워지는 날이 올까요..?

 

 

 

References

https://stackoverflow.com/questions/46513639/how-to-downgrade-java-from-9-to-8-on-a-macos-eclipse-is-not-running-with-java-9

 

How to downgrade Java from 9 to 8 on a MACOS. Eclipse is not running with Java 9

How to downgrade Java from 9 to 8 on a macOS Sierra 10.12.6(16G29) . I tried removing the Java plugin and installed Java 8, however the Java and javac version shows 9 in terminal, but In system

stackoverflow.com

https://www.lotharschulz.info/2019/08/21/mac-change-default-java-version/

 

Change Java version on Mac | Lothar Schulz

[update 2021 01 12] this post is outdated. Please refer to change default version on macOS BigSur: https://www.lotharschulz.info/2021/01/11/change-default-java-version-on-macos-11-bigsur-persist-it/ 2 minutes read Today I had to downgrade the default java

www.lotharschulz.info

https://stackoverflow.com/questions/67020698/appium-getting-a-java-lang-runtimeexception-java-lang-nosuchmethodexception

 

Appium - Getting a java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy9.proxyClassLookup() at PageFac

I am getting this exception on running an Appium test. The test fails at PageFactory with the exception below. My POM: <?xml version="1.0" encoding="UTF-8"?> <project x...

stackoverflow.com