Borgy Manotoy
Borgy Manotoy

Reputation: 2038

Bluemix Liberty Java does not build with Java 8

How can I change maven compile java version into version 8?

I applied the following:

cf set-env boldStartApp JBP_CONFIG_IBMJDK "version: 1.8.+"     
cf set-env fournHubApp JVM 'openjdk'     
cf set-env fournHubApp JBP_CONFIG_OPENJDK "version: 1.8.+"     
cf restage boldStartApp  
cf restage fournHubApp  

I already tried the solution from this forum thread: https://developer.ibm.com/answers/questions/12673/bluemix-and-java8.html

Everything I tried failed.

I am still getting the error:

Screenshot of Bluemix-maven build error

How do can I change the java version to 8 in bluemix liberty java?

Upvotes: 2

Views: 736

Answers (2)

Borgy Manotoy
Borgy Manotoy

Reputation: 2038

The following are the changes done by the ibm support to fix the building issues I am having with regards to using java 8.

Changes in pom.xml:

    <properties>    
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>    
            <maven.compiler.source>1.8</maven.compiler.source>    
            <maven.compiler.target>1.8</maven.compiler.target>    
    </properties>    

In the build stage pipeline configuration:

Edit, build shell command:

From:

    #!/bin/bash        
    mvn -B package   

To:

    #!/bin/bash    
    export JAVA_HOME=/opt/IBM/java8    
    mvn -B package   

Build Stage Configuration change(s) screenshot

  • manifest.yml

    applications:
    - disk_quota: 1024M    
            host: xxx    
            name: xxx    
            path: target/GlobalTicket-1.0-SNAPSHOT.war    
            domain: mybluemix.net    
            instances: 1    
            memory: 512M    
            env:    
                    IBM_LIBERTY_LICENSE: L-MCAO-9SYMVC    
                    JVM: openjdk    
    

Upvotes: 2

kosker
kosker

Reputation: 333

I also have tried to run Java on Liberty but it did not work out. So I've found a workound solution for that. You can create a new image from an image listed in DockerHub and use it to create a container. Here is a Dockerfile of an image that has Java installed in it:

FROM java:8-jdk

RUN apt-get update -y && \
    apt-get upgrade -y

# Set password length and expiry for compliance with Vulnerability Advisor
RUN sed -i 's/^PASS_MAX_DAYS.*/PASS_MAX_DAYS   90/' /etc/login.defs && \
    sed -i 's/sha512/sha512  minlen=8/' /etc/pam.d/common-password

EXPOSE 80

You can create the image using cf ic command:

 cf ic build --no-cache -t registry.ng.bluemix.net/mycompany/java8:v1 .

Upvotes: 0

Related Questions