Wednesday, May 21, 2008

Installing VMware Server Console in Hardy Heron 8.04

Here are the steps I followed while trying to install VMware Server Console on Hardy:
  • Install some prerequisitives: sudo apt-get install build-essential linux-headers-`uname -r` xinetd
  • Download the VMware Server Linux client package, which is a zip that contains the following components components:
    - Linux VMware Server Console (.tar and .rpm)
    - Perl scripting API for Linux (.tar)
    - Programming API (.tar)
  • Unzip the downloaded file.
  • Extract the file VMware-server-console-1.0.4-56528.tar.gz.
  • Enter the directory it was extracted into and run sudo ./
  • The installer will ask some questions. Choose the default answer on all of them.
  • Running vmware-server-console will fail with the following error messages:
    /usr/lib/vmware-server-console/lib/ version `GCC_3.4' not found (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ no version information available (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ version `GCC_4.2.0' not found (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ version `GCC_3.4' not found (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ no version information available (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ version `GCC_4.2.0' not found (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ version `GCC_3.4' not found (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ no version information available (required by /usr/lib/
    /usr/lib/vmware-server-console/lib/ version `GCC_4.2.0' not found (required by /usr/lib/
  • Create the following links:
    sudo ln -sf /lib/ /usr/lib/vmware-server-console/lib/
    sudo ln -sf  /usr/lib/ /usr/lib/vmware-server-console/lib/

Monday, May 5, 2008

Installing, configuring and using ODBC on ubuntu

I wanted to use an ODBC-MySQL bridge on my linux box. Here are the steps I followed.
  • First of all, unixodbc comes installed on ubuntu. Otherwise you can install the package called unixodbc.
  • I downloaded and installed the ODBC connector from the MySQL website. I downloaded the rpm package, converted it to a deb with alien and installed it with dpkg.
  • I also found and installed these packages in the ubuntu repositories: mysql-connector-odbc and libmyodbc. There is probably some redundancy in this step and the previous one, but at least I didn't have any conflict issues and everything worked in the end.
  • Now, unixodbc relies on two files: /etc/odbcinst.ini and ~/.odbc.ini. The first one holds a registry with ODBC drivers for different database systems. The installer for the MySQL driver (the one from the MySQL website) registers the driver with this file, so you don't need to do that manually. The file should look like this:
    DRIVER          = /usr/lib/
    SETUP           = /usr/lib/
    UsageCount              = 1
    Make sure the location of the drivers is the correct one.
  • The .odbc.ini is used for declaring datasources. Actually this file declares datasources on a per-user basis. Global datasources can be configured in the file /etc/odbc.ini. An entry on these files should look like this:
    SERVER = localhost
    DATABASE = mysql
    USER        =root 
    PASSWORD    =
    PORT        = 3306
    SOCKET = /var/run/mysqld/mysqld.sock
    Needless to say that the DRIVER name should must the name of the driver, as it was declared on /etc/odbcinst.ini.
  • As you can see I also had to explicitly define the mysql socket. This was because the location of the mysql socket in ubuntu is different than in other linux systems. By default, unixodbc uses the location /tmp/mysql.sock, so you can either explicitly specify the socket location as above, or just create a link:
    sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
  • Now you can test the connection using
    isql -v test
    You should get a message like this:
    | Connected!                            |
    |                                       |
    | sql-statement                         |
    | help [tablename]                      |
    | quit                                  |
    |                                       |
    followed by an SQL prompt.
  • Finally this is some java code that uses this datasource:
    // There are two ways we can address a datasource: 
    // either with the DNS of a correctly configured ODBC datasource, 
    // or by providing all the database information.
         Connection conn = java.sql.DriverManager.getConnection(

Monday, April 28, 2008

Hide partition icons from your ubuntu desktop

Changing the looks of the input boxes and button on Firefox

Firefox 2 looks like crap on linux. The buttons and other input widgets just look so 90s... Jesse "fatsheep" Cambon has created a nice little app to change the appearance of all the input controls (buttons, textfields/textareas/dropdowns/checkboxes etc). The app can be downloaded at ubuntuforums. You just have to download the archive, extract it, run ./install and restart firefox. That's all.

Thursday, April 24, 2008

Installing MS Word 2003 on ubuntu using WINE

Although OpenOffice is a fairly decent suite, there are still some compatibility issues between OO and MSOffice. In my experience these have to do with formatting, which just gets messed up if you open a Word document on OO and save it as a .doc. I read somewhere that these problems can probably be overcome if you install some fonts on linux, but I didn't try that.

Instead, I thought I should finally give WINE a try so I could stop dual-booting. I found a very helpful guide on Sorcerer's tech. I am using Feisty Fawn 7.10, and I only installed and tested Word. At the time of writing this, the newest version on the ubuntu repositories was 0.9.46. When I tried it out with this version, I got an error message as soon as Word launched, saying something like this: "Microsoft Word has not been installed for the current user", and then it would just close. After a quick search on the Web, I found out that I had to use an older version of Wine, so I downloaded the 0.9.37 version and everything worked fine.

Note: Accordint to the Sorcerer's tech, this should work on all flavors of linux.

Tuesday, April 22, 2008

Create a custom keyboard layout in linux

This post explains how you can create a custom keyboard layout in linux.

Tuesday, April 8, 2008

Wrapping all dependencies in a jar

Yesterday I encountered this issue: I have been writing a client code that contacts a web service. I wanted to implement a modularized solution by wrapping all web service related code and dependencies in a library, so that I could jsut use this library in my client code, without having to worry about the WS specifics (ie the web service location, how to establish connection with it etc).

So I created a package that operates as a middle layer between the WS and the client code and then packaged it into a jar file. However, when I tried to use that in an applet I realised that I also had to distribute all of the jar's dependencies with the applet. (This problem wasn't obvious while running the program as a Java application, cause JVM was able to locate the dependencies in the file system.)

I made a little research and I found out that it is not possible to include other jars in a jar file, just like you can do with war files. The suggested solution is to unpackage all jars and re-package them into your own jar. Of course this isn't something that you can easily do by hand, especially if you think that the whole process has to be repeated each time you compile your project.

So this process has to be automated and ant is one way to do that. I will be demonstrating how this can be done on Netbeans.

First a few words about how Netbeans uses ant. In your project folder you will find two build files:

  • $PROJ_HOME/build.xml
  • $PROJ_HOME/nbproject/build-impl.xml
The second one is the actual build file that Netbeans automatically creates using the project properties, and is updated each time you add a new source file, or add a new JAR to the project classpath. You should not edit this file. (Actually even if you do, your changes might be overwritten when the file is automatically regenerated.) You should only edit the first one. This file defines a number of pre and post targets that are built just before or just after the basic targets of build-impl.xml.

In our case we will use the -pre-jar target. The commands of this target will extract the library jar files into the built directory just before the jar target is called, so the latter will include them when creating the project's jar file. An example of the definition of this target is shown below.

    <target name="-pre-jar">
        <unjar src="${file.reference.axis-ant.jar}" 
        <unjar src="${file.reference.activation.jar}"  
        <unjar src="${file.reference.axis.jar-1}" 
        <unjar src="${file.reference.commons-discovery-0.2.jar}" 
        <unjar src="${file.reference.commons-logging-1.0.4.jar}" 
        <unjar src="${file.reference.jaxrpc.jar-1}" 
        <unjar src="${file.reference.log4j-1.2.8.jar}"  
        <unjar src="${file.reference.saaj.jar-1}" 
        <unjar src="${file.reference.wsdl4j-1.5.1.jar}" 
        <unjar src="${file.reference.activation.jar}" 
        <unjar src="${file.reference.mail.jar}" 

We need an unjar element for each jar we want to repackage in our jar. The dest attributes specifies that the jars should be extracted in the project's build directory; you should leave that as it is.
Now, the value of the src attribute contains a reference to the jar file that will be unjar-ed. You can find the values you should use in the file $PROJ_HOME/nbproject/private/ This properties file contains key-value pairs with the names used by Netbeans for library files and the actual location of these files.