It is the first time I use OpenShift and am creating an application DIY cartridge with Tomcat Java 8 and 8.
I am using
export JAVA_HOME="${OPENSHIFT_DATA_DIR}jdk1.8.0_51"
export PATH=$JAVA_HOME/bin:$PATH
cd $OPENSHIFT_DATA_DIR/apache-tomcat-8.0.32/bin
./startup.sh
command on my hook action_hook/start to start Tomcat 8 automatically and change the variable JAVA_HOME my application to run the java 8. The command to run the tomcat 8 is working perfectly, but to change the JAVA_HOME variable seems is not working.
But if I run the command to change the JAVA_HOME variable in my ssh console (Putty) and soon after give the java -version
command, it shows that the version is 1.8.x But when I close my shh console, open again and I run the java -version
command, it returns the version 1.7.x. Does anyone have any idea what might be happening?
Since the environment variable JAVA_HOME
is not set by default when using the DIY cartridge, you should try setting it using the rhc env set
(https://developers.openshift.com/en/managing-environment-variables.html#custom-variables) command instead of using a script in your action_hooks directory.
Something like:
rhc env set JAVA_HOME=/var/lib/openshift/<app-id>/app-root/data/jdk1.8.0_51 -a <appname>