简体   繁体   中英

DIY cartridge resets to Java 1.7 from 1.8 in OpenShift

I have read and tried all answers on stackoverflow. Im using a DIY cartridge in Openshift and the version says

java version "1.7.0_121"
OpenJDK Runtime Environment (rhel-2.6.8.1.el6_8-i386 u121-b00)
OpenJDK Server VM (build 24.121-b00, mixed mode)

I need java 1.8. I currently have this.

action_hooks

Build

#!/bin/bash
cd $OPENSHIFT_DATA_DIR

if [ ! -d apache-maven-3.3.9 ]; then
wget http://redrockdigimark.com/apachemirror/maven/maven- 3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar -zxf apache-maven-3.3.9-bin.tar.gz
fi

#Download Java8 If not already installed
if [ ! -d jdk1.8.0_05 ]; then
wget --no-check-certificate --no-cookies --header "Cookie:     oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn- pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.tar.gz
tar -zxf jdk-8u5-linux-x64.tar.gz
fi

Start

#!/bin/bash
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0
export PATH=$JAVA_HOME/bin:$PATH

$OPENSHIFT_DATA_DIR/apache-maven-3.3.9/bin/mvn -f    $OPENSHIFT_REPO_DIR/pom.xml clean package -s  $OPENSHIFT_REPO_DIR/.openshift/settings.xml

nohup java -jar -Dserver.port=${OPENSHIFT_DIY_PORT} - Dserver.address=${OPENSHIFT_DIY_IP} $OPENSHIFT_REPO_DIR/target/*.jar >   ${OPENSHIFT_DIY_LOG_DIR}/bootjava8.log 2>&1 &

Java version stays at 1.7 itself.

Please guide me.

OpenShift version 2 is EOL, not a good idea to deploy new things on it. But what you pasted works for me:

> export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0
> export PATH=$JAVA_HOME/bin:$PATH
> java -version
openjdk version "1.8.0_111"

Anyway, you need to remove java download from your deploy hook. It makes no sense provided you use the existing java.

How do you know java 1.7 is still used? With the start hook above you shold be running 1.8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM