티스토리 뷰

os

리눅스에 자바 바이너리 설치 하기

littlecarbb 2018. 7. 31. 12:49

리눅스에 자바를 설치 하는 방법은 많이 있습니다만,

저는 바이너리 압축 파일을 이용한 설치를 하려고 합니다.

yum 이나 rpg를 사용하는 방법도 있지만, 이는 개인 취향 이겠지요.



1. 자바 압축 풀기


일단 www.oracle.com 에서 받은 자바 파일을 ftp를 통해 다음 폴더에 넣었습니다.


/usr/local/src/java


java 폴더는 제가 임의로 만든 폴더 입니다.

이제 올려둔 jdk 파일의 압축을 tar로 풀어 줍니다.

tar -xvf jdk-7u75-linux-x64.gz


압출이 풀리고 나면 아래와 같이 폴더가 생성 됩니다.



저는 이 폴더 명을 좀더 간결하게 바꾸겠습니다.

그냥 두셔도 되고 폴더안의 내용을 java 폴더안에 넣어도 되지만,

자바를 버전별로깔아 쓰는 경우도 있으니, java_[version] 형태로 변경 하겠습니다.


mv jdk1.7.0_75 java_1.7



2. 환경설정


환경설정을 해주는 이유는 다들 아실겁니다.

"어디서나" 자바 명령어를 쓸 수 있게 함이죠

이건 윈도우나 리눅스나 꼭 해주는 작업 입니다.


환경 설정은 etc 폴더의 profile 에서 해 줍니다.

vi 에디터로 해당 파일을 열어 줍니다.


vi /etc/profile


vi 에디터로 profile을 열면 아래 내용 추가.



JAVA_HOME=/usr/local/src/java/java_1.7

CLASSPATH=.:$JAVA_HOME/lib/tools.jar

PATH=$PATH:$JAVA_HOME/bin

export JAVA_HOME CLASSPATH PATH



위내용을 추가 해 주고esc키 -> :wq로 저장을 합니다.



마지막으로 변경된 환경설정 파일을 적용 해 줍니다.


source /etc/profile


설치 완료~!

설치가 잘 되었는지 확인해 보겠습니다.


javac -version


아래와 같은게 보여야함.


[localhost.localdomain:badosdev():/usr/local/java-se-8u40-ri/bin(246)] javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -parameters                Generate metadata for reflection on method parameters
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -h <directory>             Specify where to place generated native header files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -profile <profile>         Check that API used is available in the specified profile
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @<filename>                Read options and filenames from file

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함