arch.ruaniz.com

Scott.Lee, Application Architect

Install and setup JAVA

Created 목요일 30 11월 2017
Installation/Setup/Configuration Java Development Kit

Script install and setup Java

1. Pre-installation setup

A. creating required operating system group and user

Create operating system group and user

B. install dependency packages

C. creating base directory

Create operating system drectory

D. firewall configuration

2. installation setup : app

A. change account

$ su - app

B. creating application directory

$ mkdir -p /apps/jdk

C. download

https://jdk.java.net/ - JDK 11.0.2 General-Availability Release
$ curl -O https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -P /apps/install
$ wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -P /apps/install

http://oracle.com - Java SE Development Kit 11.0.2(LTS)

  • for accept header and license
    $ curl -LO -H “Cookie: oraclelicense=accept-securebackup-cookie” http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.tar.gz -P /apps/install

    $ curl -O -v -j -k -L -H “Cookie: oraclelicense=accept-securebackup-cookie” http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.tar.gz -P /apps/install

    $ wget http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.tar.gz -H –no-cookies –header “Cookie: oraclelicense=accept-securebackup-cookie” -P /apps/install

D. install

decompress tarball
$ tar -zxvf /apps/install/openjdk-11.0.2_linux-x64_bin.tar.gz

copy application directory
$ cp -R /apps/install/jdk-11.0.2 /apps/jdk/11.0.2

package install

  • cenos
    $ sudo yum install java-11-openjdk-devel
  • ubuntu
    $ sudo apt-get install openjdk-11-jdk

3. post-installation setup

A. set environment variable

add JAVA_HOME environment variable to /etc/profile file or $HOME/.bash_profile file package install path : /usr/lib/jvm

$ su -
$ cat > /etc/profile.d/jdk.sh «EOF
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac)))))
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
EOF

$ source /etc/profile.d/jdk.sh

$ vi /etc/profile.d/jdk.sh

# create new
export JAVA_HOME=/apps/jdk/11.0.2
export PATH=$PATH:$JAVA_HOME/bin

$ source /etc/profile.d/jdk.sh

$ source /etc/profile

$ vi /etc/profile

...
export JAVA_HOME="/apps/jdk/11.0.2"
export PATH=$PATH:$JAVA_HOME/bin:
...

$ source /etc/profile

B. Selecting Java Versions with Alternatives

9. Appendix

reference site