리눅스 자바 설치 및 오류 정리(Linux Java installation and error correction), java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory


AWS 리눅스에 자바를 깔면서 이번에 삽질을 좀 하게 되었고, 그것을 정리하여 남겨보려고 합니다.


시간이 지난 뒤에 작성하여 다소 두서없는 내용일 수 있으니 참고하시기 바랍니다.


1. 에러 메시지: java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory



2. 상황: openJDK가 깔려 있는 리눅스에 Oracle JDK를 설치하고 java 관련 명령어를 사용했을 때.


3. 해결방법

  • 여러가지 방법을 시도했는데 어떤 것이 해결한 방법인지 확실하지 않습니다.

  • 3.1. vi /etc/ld.so.conf.d/java.conf 를 통해 아래와 같이 내용 추가 (이 경로는 저의 경우입니다)

     /usr/java/jdk1.8.0_121/lib

     /usr/java/jdk1.8.0_121/lib/amd/jli


    추가 후 ldconfig 명령어 사용은 필수입니다.

    확실하게 확인하시려면 find / -name libjli.so를 통해 libjli.so의 위치를 확인하시기 바랍니다.


  • 3.2. java, javac를 기본 명령어로 등록한다.(root 권한 필요)

 update-alternatives --install "/usr/bin/java" "java" "/usr/bin/jdk1.8.0_121/bin/java" 1;

 update-alternatives --install "/usr/bin/javac" "javac" "/usr/bin/jdk1.8.0_121/bin/javac" 1;

 update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/bin/jdk1.8.0_121/bin/javaws" 1;



 update-alternatives --set java /usr/bin/jdk1.8.0_121/bin/java;

 update-alternatives --set javac /usr/bin/jdk1.8.0_121/bin/javac;

 update-alternatives --set javaws /usr/bin/jdk1.8.0_121/bin/javaws;


이 명령어를 사용하여 java, javac, javaws 를 기본 명령어로 등록하고, 아래의 명령어를 통해 어떤 버전의 자바를 사용할 것인지 선택합니다. 물론 경로 수정은 필수입니다.


 update-alternatives --config java




저는 이 방법을 통해 해결되었고, 제대로 정리는 안되었지만 해결책을 찾으시는 분들께 조금이나마 도움이 되길 바랍니다.



아래는 혹시 모를 영문 사용자를 위한 구글 번역기를 통한 영문 번역(번역이 맞는 지는 알 수가 없다).





I've been working on Java on AWS Linux this time, and I want to keep it organized.


Please note that it may be a bit confusing to write after a time.


1. Error message: java: error while loading shared libraries: libjli.so: can not open shared object file: No such file or directory



2. Situation: When installing Oracle JDK on Linux with openJDK and using java related commands.


3. Solution: I tried several methods, but I'm not sure what worked.


  • 3.1. vi Add the following contents via /etc/ld.so.conf.d/java.conf (this path is my case)

     /usr/java/jdk1.8.0_121/lib

     /usr/java/jdk1.8.0_121/lib/amd/jli


Use of the ldconfig command after adding is required.

To be sure, check the location of libjli.so via find / -name libjli.so.


  • 3.2. Register java, javac as basic commands (root privilege required)

 

 update-alternatives --install "/usr/bin/java" "java" "/usr/bin/jdk1.8.0_121/bin/java" 1;

 update-alternatives --install "/usr/bin/javac" "javac" "/usr/bin/jdk1.8.0_121/bin/javac" 1;

 update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/bin/jdk1.8.0_121/bin/javaws" 1;



 update-alternatives --set java /usr/bin/jdk1.8.0_121/bin/java;

 update-alternatives --set javac /usr/bin/jdk1.8.0_121/bin/javac;

 update-alternatives --set javaws /usr/bin/jdk1.8.0_121/bin/javaws;


Use this command to register java, javac, javaws as basic commands, and use the following command to select which version of Java to use. Of course, route modification is a must.


 

 update-alternatives --config java



I have been solved through this method, and although it has not been properly organized, I hope to help those who are looking for a solution.



반응형