Monday 10 August 2015

Building OpenJDK9 on the Cloud... Part 2

Continued from "Building OpenJDK9 on the Cloud...Part 1".
  • Connecting to your EC2 VM using PuTTY
  • Build Open JDK9
  • Store an Image of the EC2 VM


Connecting to your EC2 VM using PuTTY


The EC2 private key that you created previously isn’t supported by PuTTY.  The EC2 private key format is .pem, whereas the required PuTTy format is .ppk.  

First convert your EC2 private key to the PuTTY format using PuTTYgen.

Then using PuTTY, enter the session details.  Add the host name (i.e. ubuntu@xx.xx.xx.xx), Port 22, Connection type: SSH and save these.  

Then load the private key by going to Connnection/SSH/Auth.  Browse for the private key created using PuTTygen and click “Open”.
You should now have access to the VM on the AWS cloud.  Well done. :) 

Build Open JDK9



Install missing packages.

You will need all of the following installs.  


sudo apt-get install mercurial make build-essential zip unzip  libX11-dev libxext-dev libxrender-dev  libxtst-dev libxt-dev libfreetype6-dev libcups2-dev libasound2-dev  ccache  g++-4.7-multilib libffi-dev

I could not get this to work in one string, as detailed in the link above, so (annoyingly) had to run each in a new command.  The open jdk code is held in mercurial so add this too.

sudo apt-get install mercurial
sudo apt-get install make
sudo apt-get install build-essential
sudo apt-get install zip
sudo apt-get install unzip
sudo apt-get install libX11-dev
sudo apt-get install libxext-dev
sudo apt-get install libxrender-dev
sudo apt-get install libxtst-dev
sudo apt-get install libxt-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libcups2-dev
sudo apt-get install libasound2-dev
sudo apt-get install ccache
sudo apt-get install g++-4.7-multilib
sudo apt-get install libffi-dev

Install Java 8. 
Java 9 is built from Java 8, so install Java 8 using instructions from the following link 
http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/ 
 
The instructions are 
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
Check the version 
$ java -version
  
Download and build JDK 9
$ hg clone http://hg.openjdk.java.net/jdk9/jdk9 jdk9
$ cd jdk9
$ chmod u+x get_source.sh
$ ./get_source.sh
$ bash configure --with-boot-jdk=/usr/lib/jvm/java-8-oracle --disable-warnings-as-errors
$ make clean images

Don’t fret if this doesn’t build in seconds.  The build took about 40 mins on a 1GB VM in Ireland, connecting from the UK. 

OK so you have connected to your shiny new VM, installed the software and built Java 9.  Hurrah! Give yourself a pat on the back.

Store an image of the VM

So that you don’t have to go through all this rigmarole again, it would be a good idea to store an image of the VM that you can use at a later date after you’ve closed and terminated the VM.  Click on “Actions/Image/Create Image”.  Give the image a name and save it.
                        



Your new AMI (Amazon Machine Image) will be viewable under the “Images” section of the EC2 Dashboard 




Now you can terminate your VM safe in the knowledge that an image has been saved for future use.

To create a new VM that uses a saved AMI
Mouse over the AMI, right click and select “Launch”.  This will bring you back to the “Select your Instance Type” page.  You could create a larger sized VM for a few pence per hour. I tried an 8 GB, 2 CPU Ubuntu m4.large.  When I loaded the AMI onto this machine I had a much faster response.

Remember to save an image of your new VM once you’ve completed your work.


And Finally.....

Do remember to terminate your VM – those few pennies can mount up if you forget about it!


That’s it.  Happy Hacking!

No comments:

Post a Comment