Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Elastic Beanstalk Java How To Get Oracle JDK

I am new to Amazon web services and have recently inherited a lot of existing services.

One of the things I've been desperately needing is for our Amazon Elastic Beanstalk instance to be using Sun's Oracle JDK rather than openJDK.

This inconsistency has been making my java functionalities not working as expected since I do java development using Sun's Oracle JDK. Our legacy code is based on JDK7.

For example, the JPEG codec doesn't exist in openJDK, and the javascript Rhino engine doesn't support a JSON.stringify function. I've made workarounds to these, but that's just avoiding the bigger issue which is that I have no idea what openJDK doesn't support, and Oracle JDK seems to support just about everything.

According to the previous owner, I was recommended not to create my own "AMI" because then I would have to take care of all the internal resources myself. I was told that doing so would defeat the purpose of Elastic Beanstalk supposedly handling everything for us.

I cannot seem to find a straight answer around. I do not want to leave the Elastic Beanstalk ecosystem. I'm under the assumption that Amazon's EC2 is a whole different ecosystem where I would have to manage all the server's internals myself.

I just want to know, as of this current day, is it possible to have an Elastic Beanstalk instance for Tomcat7 with Oracle JDK?

I am hoping that it is simply a simple configuration change somewhere on the site.

If possible, can you please provide instructions as to how to do so?

like image 620
Mike Davis Avatar asked Oct 30 '22 16:10

Mike Davis


1 Answers

You can install you preferred JDK and change the java linux link to it, so it'll be the default one. Since EB instances are automatically created and destroyed by EB, you need to include a small script that instructs EB to make the required java change whenever it decides to spin up a new web instance.
Now to do that you need to need to write a conf file and place it in a .ebextensions folder. in that file you manually install java and replace it with the current one.

The formal (tiring) documentation about eb config files is here.
To get you up and running fast, check out this gist.

like image 75
Tal Avatar answered Nov 11 '22 09:11

Tal