Confessions of a Linux newbie

Well, it happened again (to be versed on the lines of a famous track)! And I was awed by the charms of Ubuntu 7.10.

Being the newbie that I am in Linux, I was looking for a distribution which would leave little for me to do, when it comes to installation, and getting the hardware working. I remembered hearing the name ‘Debian’ a number of times from some Linux pros. I downloaded 4.0_r2, burnt the basic installation, and tried installing.

Set-up wasn’t a hassle, apart from some minor hiccups. It’s later that I realised that those hiccups would actually pose a bigger issue. Once installed, the poor OS, couldn’t detect the graphics card, and X crashed. Some googling made me download Linux-specific drivers for the card.
But since, my Debian install was a basic one, I couldn’t build it. That led me to another issue. Using ‘apt’ required the setting up the wireless card. And to get the drivers running for the wireless, there’s a dependency on a MAC package. Building MAC package required, probably, Debian source to be available. Which takes us back to the issue of Debian being a basic install (Chicken-and-Egg?)

After hours of effort, and no progress, I finally gave-up!

I also had the Ubuntu 7.10 disk downloaded ‘just-in-case’. My case, it seemed, was strong enough to give it a try. And that’s the basis of the awe that I mentioned in the beginning.
With absolutely no hassle, almost every hardware on the machine got detected. Even the wireless, which I expected the least! The only issue is getting sound to work, which, I presume would take little effort (aka googling.) I am glad.

I loved the GUI, and the fact that it’s supported for free by a group of people who are enthusiastic about free software. Can’t help them much technically, but I guess there are other ways I could. Let’s see. Once installed, the Synaptic updater got me the latest recommended security patches.

Aside to the above: Seems so cool, when you show-off your Linux installation to the Windows junta. The other day, I was telling someone…that I do an ESR in this office, just because I worked in NCST for some time. 🙂

Anyways, final word: if you’re new to Linux, do give Ubuntu 7.10 a try. You’ll love it!

References (apart from the links included above):
1. http://www.linux-on-laptops.com/hosted/Dell-Vostro-1400-Ubuntu-Gutsy.html: On how to get Ubuntu working on Dell laptops (the write-up is for Vostro, but I guess it would be more or less the same for Inspiron/Latitude range)
2. http://www.ubuntu.com/getubuntu: Get Ubuntu
3. http://www.ubuntu.com/products/whatisubuntu/desktopedition: Ubuntu info
4. http://www.debian.org/distrib/: Get Debian.

Sorting using Comparable or Comparator

Of late, I’ve been involved in taking some interviews. Many of the candidates seem to be confused about the very simple concept of Comparator and Comparable.
Comparable is an interface in which the contract is to provide your implementation of compareTo() method. For example:


// compares on the basis of last name
class MyVO implements Comparable{

private String firstName;
private String lastName;
...
public int compareTo(Object o){
return lastName.compareTo(((MyVO)o).getLastName());
}

...
}

Whereas, Comparator is similar to the C concept of function pointers (functors). In Java, we incorporate this by defining a class which implements Comparator, and overriding compare() method.
If we think a bit broad, we can relate to Strategy design pattern — provide different Comparator implementations for different situations. For example, you could switch from sorting on the basis of firstName instead of

lastName at runtime, based upon user-input.

A comparator implementation is as follows.


class LastNameComparator implements Comparator{

public int compare(Object o1, Object o2){
return ((MyVO)o1).getLastName().compareTo(((MyVO)o2).getLastName());
}

}

Once this is done, there are numerous ways in which you could sort your Collection.

See: Using the Strategy Design Pattern for Sorting POJOs

Adding a local user under Cygwin

Suppose we want to add Gromit [password: passw0rd] as a Cygwin user.
Issue the following commands on the console:

$ net user Gromit passw0rd /add /yes
$ mkpasswd -l -u Gromit >> /etc/passwd

The first line adds a new user under NT.
In the second line we’re appending the user password to the existing list of passwords. Now, create a directory in /home for the new user:

/home/Gromit

…and make Cygwin aware of the new user.

Note that the user won’t be able to login until NT has a place to store his/her profile. For this, either login as that new user (on local machine), or issue a command to create a directory

<sysDir>\Documents and Settings\Gromit

…and we should be done!


Reference taken from here

SLSB to Spring

Recently we were stuck-up in a seemingly easy interaction of EJB and Spring. More specifically Stateless Session Bean (SLSB) to Spring.
We went through a number of examples present on the Internet, but nothing seemed to provide a clear-cut approach. Or, maybe, they expected me to be intelligent enough :).

Here, I present the solution which finally worked for us. This example uses Weblogic 8.1 server. We’ve not tested it on any other server. I’ll update this post as and when we test it on other servers.

Continue reading SLSB to Spring