Creating a DEB package for Oracle Java

Linux based operating systems comes by default with Open JDK installations. Often it is necessary for various developmental needs to install the Oracle Java. Oracle only supplies two installations of Java for Linux based operating systems – a rpm and a tar.gz binary distribution.

For RPM based distributions it is fairly easy to have the uniform setup on a large farm of servers, but on DEB based distributions a lot of manual work needs to be done at each host after unpacking the tar.gz file such as updating the alternatives etc to make the Oracle Java a default Java installation.

I have been thinking about how to deploy Oracle Java SDK on multiple Debian servers in a standardized way i.e by creating a DEB file.

A search on Debian Packages revealed the existence of a tool called – “make-jpkg”, a part of “java-package” package. This tool is capable of creating a DEB package from this tar.gz file. Here is how I created the package –

$ sudo apt-get install fakeroot java-package

I downloaded the Oracle Java Standard Edition  on my Linux Mint Debian Edition (LMDE) virtual machine.

Next I ran the command –

$ fakeroot make-jpkg --full-name "Ajitabh Pandey" --email "ajitabh@unixclinic.com" /home/ajitabhp/Downloads/jdk-7u25-linux-x64.tar.gz

I got an error stating “No Matching Plugin was found”

Just above this error message the plugin path was given for various plugins used by this utility – “make-jpkg”. The plugins were in /usr/share/java-package directory in the form of “.sh” files (shell scripts). I next opened each shell script to try and decipher them and found the possible problem in the plugins “/usr/share/java-package/oracle-j2*.sh”. The following pattern picked up from “/usr/share/java-package/oracle-j2sdk.sh” was the culprit –

"jdk-7u"[0-9]"-linux-x64.tar.gz") # SUPPORTED
j2se_version=1.7.0+update${archive_name:6:1}${revision}
j2se_expected_min_size=180 #Mb
j2se_priority=317
found=true
;;

If you see this pattern, it clearly indicates that it is only supporting up to update 9 of the JDK and the JDK I downloaded was update 25. So I added the following lines just below the above lines to add the support for my version.

"jdk-7u"[0-9][0-9]"-linux-x64.tar.gz") # SUPPORTED
j2se_version=1.7.0+update${archive_name:6:2}${revision}
j2se_expected_min_size=180 #Mb
j2se_priority=317
found=true
;;

There are two differences, one in first line and the second in second line. I am sure you will be able to spot them and decipher them.

After making similar changes in the other oracle* files I ran the make-jpkg as mentioned above and it created a DEB file – oracle-j2sdk1.7_1.7.0+update25_amd64.deb, which is deploy-able with the usual “dpkg -i”.

Changing the Default Java Installation to the Oracle Installation

After installing the package, you may want to change some alternatives in order to make the Oracle JDK and associated JRE installations as defaults. As the default version of Java may be something different. You can check the current version of java and its provider by –

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
$ file `which java`
/usr/bin/java: symbolic link to `/etc/alternatives/java'
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Aug 16 20:18 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java

First find out the name of the available installations –

$ /usr/sbin/update-java-alternatives -l
j2sdk1.7-oracle 317 /usr/lib/jvm/j2sdk1.7-oracle
java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64

We will switch our default Java to “j2sdk1.7-oracle” with the following command –

$ sudo /usr/sbin/update-java-alternatives -s j2sdk1.7-oracle

Now you can check your Java version by

$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
$ file `which java`
/usr/bin/java: symbolic link to `/etc/alternatives/java'
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 41 Aug 16 20:22 /etc/alternatives/java -> /usr/lib/jvm/j2sdk1.7-oracle/jre/bin/java

Posted in FLOSS, Tips/Code Snippets | Tagged , , | 1 Comment

Questions of Travel

Questions of Travel Cover PhotoThere are two parallel stories running in this book. One story is of Laura Fraser, who was born and brought up in Sydney and the other is of Ravi Mendis, born and brought up in Sri Lanka. This book describes life and experiences of two different people. The author has beautifully described in great details the various places and times which both of these people lived.

Its a very slow novel and needs a lot of concentration and regularity in reading. This is the first novel of this kind which I have read. It took me some time to finish this. At the end I feel that there was too many details and the focus of the book was more of an artistic touch. I could not relate with either of the two characters in this book.

Posted in Book Reviews | Tagged , , | Leave a comment

Bad Luck And Trouble (Jack Reacher #11)

Bad Luck and Trouble Book Cover ImageIn addition to his standard folding toothbrush, Jack Reacher started carrying his passport as his identity document and an ATM card to withdraw cash from his account. This is a good progress into the “civilized world” for a guy like Reacher.

One fine day while withdrawing cash, he saw a deposit with a very strange looking number, something which triggered an alarm in his sub-conscious. After validation the source of deposit from his bank, he realized its a call from a fellow officer seeking help, and he proceeded immediately to LA. Upon his arrival he found that 4 out of his old team of 8 special investigators from Army days is missing and perhaps dead. And Reacher got involved in the investigations along with the remaining members of his team. It turns out a mix of arms/defense technology and terrorism related stuff.

It was a pleasure seeing Reacher working in a team, rather than the usual “alone”. He seems to also realize that they are getting out dated in terms of modern methods of investigation and are being out-smarted by other folks. In this case, Reacher manages to secure some finances for himself so that he can continue for some more time without having  to work somewhere in order to replenish his depleting bank reserves.

Let us see what happens in the next book in the series.

Posted in Book Reviews | Tagged , , | Leave a comment

The Hard Way (Jack Reacher #10)

The Hard Way Book CoverJack Reacher is back in the New York City having his favorite coffee shots in a shop and observing the street. He saw and ignore a man getting in a wrongly parked car and driving in it until the next evening when he visited the same coffee shop (quite unusual for Reacher to be at same place twice) again. He found a man inquiring about any customers present last evening.

This changed his next few days when he was involved in investigating the kidnapping of a wife, a daughter and missing driver cum bodyguard. He found himself in the midst of mercenaries and got involved with an ex FBI investigator, visited London, found the truth, tried to correct some wrong doing and so on and so forth.

The Hard Way is another classic Reacher thriller.

Posted in Book Reviews | Tagged , , | Leave a comment

The Enemy (Jack Reacher #8)

The Enemy Book Cover Image“The Enemy” is the 8th book in the “Jack Reacher” series by Lee Child and this book is a class in itself. Unlike the previous books where Jack Reacher was shown as an X-Army MP, an ultimate loaner finding trouble where he goes, this book is a based on Reacher’s past life during his Army days from the 1990’s.

In this book we got a chance to spend some moments spent with Reacher’s mother and brother. We get to know some historical facts about Reacher’s mother from the day’s of the world war II.

The book starts with the death of an Armoured General in a cheap New Carolina motel under disturbing circumstances. Further in the first few pages we get to know that Reacher was transferred out of Panama to North Carolina on the new year’s eve. Then a sequence of murders start, some of which implicate Reacher himself and it was looking like he got himself in trouble with some delta force Sargent’s. Reacher saw that along with 20 other elite unit major’s, his CO, Col Garber got transferred same night and a bureaucratic Col replaces him who did not want Reacher to investigate the murders and bury them. Reacher being Reacher continues the investigation along with a young lady Lt, found the culprits and risk being court martialed but ended up loosing rank and seniority.

A very gluing book, a must read for Reacher fans.

Posted in Book Reviews | Tagged , , | Leave a comment