How to update sun jdk 7 on Ubuntu 12.04

java logo

Oracle has released  JDK 7 Update 6 with JavaFX 2.2 Final for GNU/Linux, Mac OS X and MS Windows last week. I have already written how to install Sun JDK 6-7 on Ubuntu 12.04. I want to write how to update JDK 7 Update 6 manually.

Update JDK 7u6:

If you want to manually upgrade to a new version, first uninstall the JDK 7 and then reinstall. You can check your java version in console "java -version” or online here: Verify java version

Package manager: Those who have already installed an older version of Sun Java via the package manager, removes the same way.

  • First, close the web browser (because of java browser plugin).
  • Remove the Java version from the alternatives system:
sudo update-alternatives --remove "javac" "/usr/lib/jvm/jdk1.7.0_04/bin/javac"
sudo update-alternatives --remove "java" "/usr/lib/jvm/jdk1.7.0_04/bin/java"
sudo update-alternatives --remove "javaws" "/usr/lib/jvm/jdk1.7.0_04/bin/javaws"
  • Remove the browser plugin link:
sudo rm /usr/lib/mozilla/plugins/
  • Remove the jdk directory:
sudo rm -rf /usr/lib/jvm/jdk1.7.0_04

Netbeans note: If you uninstall old JDK, NetBeans 7.2 is not starting. Open the netbeans.conf file under etc directory and change the netbeans_jdkhome parameter to the new jdk path.


Happy coding.

PostgreSQL installation and settings on Ubuntu 12.04


Updated for Ubuntu GNU/Linux 13.04 (Raring Ringtail).

  • Install latest PostgreSQL 9.1 in console:
sudo apt-get install postgresql libpq-dev
  • PostgreSQL has a super user is called postgres. Change user to the PostgreSQL user:
sudo su - postgres
  • Change password of postgres user:
psql -d postgres -U postgres
psql (9.1.3) Type "help" for help
postgres=# alter user postgres with password 'YOUR_NEW_PASSWORD';
postgres=# \q
#logout postgres user
  • Restart the PostgreSQL server:
sudo /etc/init.d/postgresql restart

pgAdmin III: PostgreSQL administration and management tools

  • If pgAdminIII is not installed, the installation is easy:
sudo apt-get install pgadmin3
  • Open pgAdminIII and add new localhost server. Go to menu File > Add Server as the following screenshot:


Set up pgAdmin III server instrumentation:
When connecting to a PostgreSQL database using pgAdmin you may receive an error letting you know that the server instrumentation is not installed.

  • Install postgresql-contrib package:
sudo apt-get install postgresql-contrib
  • Install adminpack extension:
sudo -u postgres psql
postgres=# CREATE EXTENSION "adminpack";
postgres=# \q

Internationalisation tips for Java and JavaFX


java logo

Java internationalisation (i18n) tips:

I do not like large Resource Bundle files when I write multi-language desktop applications in Swing or JavaFX. So I wanted to use a resource file for each module in my applications. I’ve written a util class  with enum as below. Now I can use this utility from anywhere.

package com.devsniper.lagoserp.util;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

 * Resource Bundle helper.
 * Each module has its own resource bundle file for i18n strings.
 * Always read default locale from Locale.getDefault().
 * Use of I18n:
 *      I18n.MODULE_NAME.getString("stringKey");
 * @see ResourceBundle
 * @author cem ikta
public enum I18n {
    // module with resource files

    private ResourceBundle resourceBundle;

    I18n(String bundleFile) {
        resourceBundle = ResourceBundle.getBundle(bundleFile);

     * Gets a string for the given key from resource bundle.
     * @param key the key for the desired string
     * @return the string for the given key
    public String getString(String key) {
        try {
            return resourceBundle.getString(key);
        } catch (MissingResourceException e) {

            return "err#";

Call to use only I18n.MODULE.getString(“stringKey”)
I have two ResourceBundles for English and for German.

// set default locale english
Locale.setDefault(new Locale("en", "EN"));
// set default locale for German
// Locale.setDefault(new Locale("de", "DE"));
AppView appView = new AppView();