Installing Oracle Java: Difference between revisions

From Alpine Linux
m (+ link Shahar Valiano 2019)
No edit summary
Line 1: Line 1:
Using java requires having grsec play nice with the binaries. You may also want to install the JDK instead of the JRE depending on your use case.
Using java requires having grsec play nice with the binaries. You may also want to install the JDK instead of the JRE depending on your needs.


This guide assumes you're running as root.
This guide assumes you're running as root.
Line 10: Line 10:
  sudo tar -zxvf XXX-XXX-linux-x64.tar.gz  
  sudo tar -zxvf XXX-XXX-linux-x64.tar.gz  


Note down the directory, e.g. /opt/java/jdk1.8.0_121, create a symbol link as the current version:
Take note of the directory, e.g. /opt/java/jdk1.8.0_121, create a symbolic link as the current version:


  ln -s /opt/java/jdk1.8.0_121 /opt/java/current
  ln -s /opt/java/jdk1.8.0_121 /opt/java/current
Line 21: Line 21:
  sh /etc/profile.d/java.sh
  sh /etc/profile.d/java.sh


Now we need manage grsec with paxctl use this command to check if its installed:
Now we need manage grsec with paxctl. Use this command to check if its installed:
  which paxctl
  which paxctl


Line 28: Line 28:
  apk add paxctl
  apk add paxctl


Now in your /opt/java/XXX/bin folder let it execute:
Now in your /opt/java/XXX/bin folder, execute:
  paxctl -c java
  paxctl -c java
  paxctl -m java
  paxctl -m java
Line 38: Line 38:
You can do this for any other binary you need to use.
You can do this for any other binary you need to use.


NOTE: I read online that some people required using this command to get it working (and it may be a better alternative):
NOTE: some users have reported they had to use this command to get it working:


  setfattr -n user.pax.flags -v "mr" java
  setfattr -n user.pax.flags -v "mr" java

Revision as of 06:17, 29 July 2021

Using java requires having grsec play nice with the binaries. You may also want to install the JDK instead of the JRE depending on your needs.

This guide assumes you're running as root.

Download XXX-XXX-linux-x64.tar.gz from either the JRE or JDK section here: https://www.oracle.com/technetwork/java/javase/downloads/index.html

mkdir -p /opt/java
cd /opt/java
sudo tar -zxvf XXX-XXX-linux-x64.tar.gz 

Take note of the directory, e.g. /opt/java/jdk1.8.0_121, create a symbolic link as the current version:

ln -s /opt/java/jdk1.8.0_121 /opt/java/current

Create a file in /etc/profile.d/java.sh:

export JAVA_HOME=/opt/java/current
export PATH=$PATH:$JAVA_HOME/bin

Execute this script or restart your shell:

sh /etc/profile.d/java.sh

Now we need manage grsec with paxctl. Use this command to check if its installed:

which paxctl

If nothing comes up install it:

apk add paxctl

Now in your /opt/java/XXX/bin folder, execute:

paxctl -c java
paxctl -m java

If you have the JDK, you need to do the same to javac:

paxctl -c javac
paxctl -m javac

You can do this for any other binary you need to use.

NOTE: some users have reported they had to use this command to get it working:

setfattr -n user.pax.flags -v "mr" java
setfattr -n user.pax.flags -v "mr" javac