1

I changed the file name .openshift/markers/java7 to java8 but now when i start the gear it uses java 6 instead of java 8 and fails when trying to load classes with java 8 code. How can i make the app use java 8? I use Tomcat 6 (JBoss EWS 1.0) in openshift.

mike27
  • 965
  • 3
  • 12
  • 22

1 Answers1

0

As stated in openshift documentation about the java8 tomcat marker:

Will run Tomcat with Java8 if present. If no marker is present then the baseline Java version will be used (currently Java6)

It seems that Java 8 is not present in your server, and that is why it is falling back to Java 6.

All you need to do is to make Java 8 available in your server (as described in this answer):

rhc ssh yourAppNAme


cd $OPENSHIFT_DATA_DIR
cdwget --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
export PATH=$OPENSHIFT_DATA_DIR/jdk1.8.0_05/bin:$PATH
export JAVA_HOME="$OPENSHIFT_DATA_DIR/jdk/jdk1.8.0_05"

And add the folowing lines to your start action hook (.openshift/action_hooks/start)

export JAVA_HOME="$OPENSHIFT_DATA_DIR/jdk/jdk1.8.0_05"
export PATH=$OPENSHIFT_DATA_DIR/jdk1.8.0_05/bin:$PATH
Community
  • 1
  • 1
  • Java 8 is present at `/etc/alternative/java_sdk_1.8.0` then what should be the problem? – Ankur Raiyani Feb 19 '16 at 14:30
  • What about your $JAVA_HOME / $PATH variables? They contain that given path? Your if your app's start action hook are setting their values. – Lamoglia Feb 20 '16 at 15:36
  • Yes they have the above export lines. I restart the application from Openshift Web Console then SSH to app and run `java -version` it shows `java 7` version – Ankur Raiyani Feb 20 '16 at 15:47