Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Oracle Java 7 in an Amazon Elastic Beanstalk instance

Has anyone one come up with a good config script to install Oracle Java 1.7 in to an Elastic Beanstalk instance using the config files stored in .ebextensions. I am using a tomcat7 version of elastic beanstalk and I was able to install openJDK with yum using the following:

packages:
  yum:
    java-1.7.0-openjdk: []
    java-1.7.0-openjdk-devel: []

commands:
  use_java7:
    command: alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

How ever I would like to use Oracle Java 1.7 not OpenJDK and yum does not have that in it's repo natively.

like image 396
Matt Avatar asked Sep 23 '13 20:09

Matt


2 Answers

try this configuration file

files:
  "/home/ec2-user/install-oracle-jdk.sh":
    mode: "000755"
    owner: ec2-user
    group: ec2-user
    content: |
      #!/usr/bin/env bash
      wget -O jdk-7u25-linux-x64.rpm --no-cookies --no-check-certificate --header 'Cookie:gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup-cookie' 'http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.rpm'      
      rpm -Uvh /home/ec2-user/jdk-7u25-linux-x64.rpm
      alternatives --install /usr/bin/java java /usr/java/default/bin/java 3
      alternatives --set java /usr/java/default/bin/java

commands:
  execute-install-oracle-jdk-script:
    command: ./install-oracle-jdk.sh
    cwd: /home/ec2-user
like image 112
study Avatar answered Sep 22 '22 14:09

study


You could alternately install it as you would normally do and use this ami as your ami for creating new ec2 instances.

like image 40
sanket Avatar answered Sep 23 '22 14:09

sanket