Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Category: Tips/Code Snippets

  • 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

  • Nokia Asha 310 – Sync Contacts With Google Contacts using SyncML

    Nokia Asha 310 Image
    Nokia Asha 310

    Today I swapped my aging 4 year old Nokia 5800 Xpress Music with Nokia Asha 310 (Dual SIM with WiFI) from a local mobile store. The phone after the swap cost me Rs 3600/-.

    From last more than 8 months or so Android is my primary phone and prior to that for close to two year it was Blackberry. Along with these two devices I was using Nokia 5800 Xpress Music and another Nokia 500 for my second phone.

    The primary requirement I had was to ensure that I find some way of syncing contacts with google contacts as my android is configured to do so. This provides me a backup of all my contacts at google and will ensure that I can enter/edit my contacts at one devices and they will be available everywhere. Also google provides ability  to recover contacts (upto a certain amount of time) in case they are accidently deleted.

    In order to sync contacts I used SyncML. Support for which is enabled by google from quite some time.

    In order to configure Nokia Asha 310 to sync with google contacts, follow the following steps. We need to start with creating a personal configuration option first –

    • settings -> configuration -> personal configuration -> add new
      • Specify the account name. Anything will work here as it is just an identifier text entry, in case you are syncing from  multiple sources. My account name is “Gmail Contacts”.
      • server address should be https://m.google.com/syncml
      • username must be your username including the domain name (e.g something@gmail.com). If you are using google apps then you should use that domain instead of gmail.com.
      • password must be your password. You will be asked to enter it twice for verification.
      • contacts database -> database address is the one which is important for us as we will be syncing with it. For Gmail (and Google Apps) you should specify ‘contacts’ here. There is no need to specify username and password again here.
      • calendar database -> database address should have the value of ‘calendar’. In case you do not want to sync calendar you can leave it blank.
      • notes database -> database address should have the value of ‘notes’. In case you do not want to sync notes you can leave it blank.
      • use pref. acc. point – Set this to either ‘Yes’ or ‘No’. In case you set it to ‘No’ the you need to setup the access point values. I have set it to ‘Yes’, so that whatever my preferred access point at the time of sync is, will be used.

    NOTE Database names is a place where SyncML protocol lacks standardisation as different providers use different names, so you must know the database name in case you have a different provider.

    Next the sync settings can be configured as below –

    • Settings -> sync & backup -> sync with server -> sync settings
      • synchronised data – select the databaes which needs to be synced here. I have all three databases viz. contacts, calendar and notes selected
      • sync settings – Since this is a dual SIM phone, you will have to select either SIM1 or SIM2 and the select the configuration profile which you created above viz. ‘Gmail Contacts’.
      • automatic sync – This can be set to daily, weekly, monthly or off modes. In case you set it to off then you need to initiate sync manually when you wish to sync the databases.
      • rules for incoming – There are three possible values – Always allow, Always reject, Confirm first. The meanings are obvious. The first will always allow the incoming data and sync it, the second will always reject incoming data (in this case changes on your phone will be sent, but changes from google server will not be received) and confirm first will prompt for appropriate action each time. My setting is ‘Always allow’
    • Settings -> sync & backup -> sync with server -> sync now can be used to initiate the manual sync.

    Hope this post will help interested folks.

  • Enable Apache mod_rewrite module on OpenSuSE

    OpenSuSE has mod_rewrite installed, but it is not loaded by default. Check if mod_rewrite is actually loaded by default or not:

    # grep "^APACHE_MODULES" /etc/sysconfig/apache2
    APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5"

    (more…)

  • Locale Problems in Debian and Ubuntu

    Recently I have been facing some issues with locales in Debian and Ubuntu based Xen based virtual servers. These typically appear while running the man command and apt-get or dpkg commands.
    (more…)

  • OpenSolaris – Desktop Experience – Part 1

    Installation

    Few days back I installed OpenSolaris 2008.11 on my aging IBM R50e Thinkpad. My previous experience with OpenSolaris Solaris Express builds were not that great from desktop point of view. Primary problem being no support for the Intel Pro Wireless adapter IPW2200B/G and the multimedia support. This time LFY distributed a live CD of OpenSolaris 2008.11, so I thought of trying my hands on it. Immediately after booting I was impressed with the desktop which came up and reminded me of my first Ubuntu experience. A quick glance at the top-right panel and I saw two network interfaces iwi0 and iprb0. Hmmm, so it picked up both my network interfaces. Its a pity that unlike last time, I do not have a wireless network to connect to, but I was able to see the list of all networks which could be found. The overall interface looked good and quite similar to Ubuntu, so it was familiar to me.
    (more…)