Friday, February 22, 2008

Sharing Windows XP folder with Ubuntu

Since i'm new to ubuntu, all my files were basically residing in windows xp.
As i was working with ubuntu, i thought of relaxing a bit by viewing some photos taken recently. But all of them were sitting inside my xp and i need some way to access it.

Transferring them via usb is an option, but i wanted an even elegant solution. Then i came to know that VirtualBox supports "sharing" folders between "host" and "guest" operating systems.

I read in the VirtualBox manual, that "sharing" folders between "windows" host and "windows" guest is more or less seamless. But "sharing" between "windows" host and "linux" guest need some additional work.

But it's not very tough.

First i needed to configure the shared folder in my VirtualBox. I clicked the menu "Devices->Shared Folders" to configure the sharing. And I choose a folder in my xp machine and gave a share name to that.

Then i opened the terminal in ubuntu and created a directory called share under "mnt" so it looks as "/mnt/share". This required "admin" privileges.

Then i executed the command: sudo mount -t vboxsf myphotos /mnt/share
in the terminal. That's it.

And this how it looked after that in the FileBrowser:

Best applications in Ubuntu-7.10

Though there are some very good applications integrated in the default ubuntu installation, these are the one which i love most (as of now):

- GParted (Undoubtedly very very good. Extremely powerful. I use the GParted in the ubuntu livecd to resize/partition even my windows xp drives)
- Tomboy notes (Very handy, something like the "Scratchpad" in Google Desktop)
- Calculator (Really amazing, the calculator in windows xp looks very ugly to me now)

Increasing the screen resolution of Ubuntu-7.10 on VirtualBox

Oops...finally i managed to configure my ubuntu screen resolution to the fullest.

I have a Dell Vostro 1400 laptop with Windows xp professional. Ubuntu runs on my machine on top of VirtualBox.

But I never enjoyed working with ubuntu, since all i was able to view the ubuntu desktop at the resolution "800x600" only.

After searching through the web, I finally managed to get the full resolution supported by my notebook. (1280x800).

These are steps i followed:

- installed the virtual machine add-ons provided by VirtualBox
- opened the /etc/X11/xorg.conf file and added the the resolutions "1280x800" and "1024x768" under the "Screen" section...

So here is how my xorg.conf file looks now...

----------------------------------------------------------------------------------------------
# xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the xorg.conf manual page.
# (Type "man xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
# sudo dpkg-reconfigure -phigh xserver-xorg

Section "Files"
EndSection

Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Configured Mouse"
Driver "vboxmouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "true"
EndSection

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "HorizEdgeScroll" "0"
EndSection

Section "InputDevice"
Driver "wacom"
Identifier "stylus"
Option "Device" "/dev/input/wacom"
Option "Type" "stylus"
Option "ForceDevice" "ISDV4" # Tablet PC ONLY
EndSection

Section "InputDevice"
Driver "wacom"
Identifier "eraser"
Option "Device" "/dev/input/wacom"
Option "Type" "eraser"
Option "ForceDevice" "ISDV4" # Tablet PC ONLY
EndSection

Section "InputDevice"
Driver "wacom"
Identifier "cursor"
Option "Device" "/dev/input/wacom"
Option "Type" "cursor"
Option "ForceDevice" "ISDV4" # Tablet PC ONLY
EndSection

Section "Device"
Identifier "Generic Video Card"
Driver "vboxvideo"
BusID "PCI:0:2:0"
EndSection

Section "Monitor"
Identifier "Generic Monitor"
Option "DPMS"
EndSection

Section "Screen"
Identifier "Default Screen"
Device "Generic Video Card"
Monitor "Generic Monitor"
DefaultDepth 24
SubSection "Display"
Modes "1280x800" "1024x768" "800x600"
EndSubSection
EndSection

Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"

# Uncomment if you have a wacom tablet
# InputDevice "stylus" "SendCoreEvents"
# InputDevice "cursor" "SendCoreEvents"
# InputDevice "eraser" "SendCoreEvents"
InputDevice "Synaptics Touchpad"
EndSection

-------------------------------------------------------------------------------------------
And the only change i made was here:

Section "Screen"
Identifier "Default Screen"
Device "Generic Video Card"
Monitor "Generic Monitor"
DefaultDepth 24
SubSection "Display"
Modes "1280x800" "1024x768" "800x600"
EndSubSection
EndSection

I just added "1280x800" "1024x768" under the SubSection "Display".

Fortunately this worked for me.

(Note: I actually got this information from a VirtualBox forum thread and I sincerely thank the guy who provided this information. Thank you very much really)

Whatmore, if you choose the "Full screen mode" in VirtualBox, you get a feeling of just running ubuntu...

Ya, now i feel, i can slowly leave behind windows xp behind me...

Thursday, February 21, 2008

Fedora 8 added to my Linux armour

First ubuntu, then open suse, now fedora....

Yes, now I have Fedora 8 installed on my machine, courtesy VirtualBox.

One interesting thing is they all have a fairly similar user interface. And all the three look very promising and very interesting.

Interesting times ahead...

(I would like to explore solaris next. If you have installed solaris on top of VirtualBox, please offer your suggestions to me)

Control System and source code quality

Sun and other pioneers have done a great job in defining some code conventions and best practices for java development. We all know that it would be easy to maintain our java codes, if we follow these conventions and best practices.

A basic rule in Control Systems is, if you want to control some process, you need the feedback signal, so that you can regulate it.

Say, you press the accelerator in your car. You would like to know at what speed you are driving, by looking at the speedometer. Then you would like to cruise often having a look at your speedometer to control your driving speed.

So, you need some device/instrument, here in this case a speedometer, to monitor/control some process.

(Needless to say that i'm an electronics and instrumentation graduate :)

Likewise, to control the quality of your code, you need some device/instrument to give you feedback/measurement of the quality of code, so that you can take actions based on it.

It's one thing to say to your team members, "Guys, the source code you write must follow the code conventions we have defined" and not enforcing a way to monitor it.

CheckStyle is one such tool to aid you in controlling the quality of your code. CheckStyle defines a set of "rules", which must be followed by the source code.

The rules are very simple to use and configure. You can configure them in a xml file. An easy way to start learning CheckStyle is to have a look at the sun_checks.xml file that comes along with the downloads.

Rules are defined as "modules". A simple rule regarding the brace position might look like this:

<module name="LeftCurly/>

This rule checks the position of the left curly bracket "{" in your java source. The default position is "end of line", which means:

public void myMethod() {
//do something...
}

But if your organization enforce some thing like this:

public void myMethod()
{
//do something...
}

you can configure CheckStyle to achieve that like this:

<module name="LeftCurly"/>
<property name="option" value="nl">
</module>

Or, if you want to enforce that all your methods must contain javadoc statements, it's very easy to achieve with a simple CheckStyle rule:

<module name="JavadocMethod"/>

To find unused, redundant imports in your java source code, just do this:

<module name="UnusedImports"/>
<module name="RedundantImport"/>

To make things much easy for the developers, CheckStyle offers many types of integration. You can either opt to run it from command line, integrate in your build process using ant/maven or directly integrate it with your IDE of choice.

We use both the IDE integration and the ant integration options.

If you are a NetBeans user, there are two nice plugins available:
1. CheckStyle4nb
2. CheckStyleBeans

The first one can be used to run CheckStyle rules on a java source file, package(s).
The second one integrates deeply into the IDE and marks the CheckStyle rules violations in the left side bar of NetBeans.

I use the first plugin a lot.

As the name implies, CheckStyle is more intended to check the "style", "formatting" of your java source code, though it contains some rules to find out some "bugs" in your code as well.
But finding "bugs" and "logical mistakes" in your source code is not which CheckStyle claims to do. PMD, FindBugs might be the right candidates for that job.

But I can assure you that CheckStyle will definitely make your java source code look better and easy to maintain. Be sure to check it out, if you haven't done so far.

Tuesday, February 19, 2008

OpenSuse 10.3 on VirtualBox

Impressed by ubuntu and being helped by VirtualBox, I decided to explore further into the linux world.

So I thought of installing openSuse 10.3 on my VirtualBox. I downloaded the gnome "live cd" (iso image) from opensuse.org. The download size was around 643 MB and it took quite some time to download the image.

Then I started VirtualBox and added a new empty virtual machine named "OpenSuse-10.3" along with the necessary virtual hard disk. I decided to give 8 GB and 512 MB RAM for opensuse.

Then i mounted the downloaded "iso" image to the virtual machines cd drive and started the empty virtual machine. So the open suse live cd booted (much like ubuntu live cd environment) and then i clicked the "install" icon on the live cd's desktop.

To my surprise, the installation was very very fast and amazingly simple. I would say that my opensuse installation experience was better than what I experienced with ubuntu.

Though ubuntu installation is also quite easy and smooth, opensuse installation was like installing a normal windows application. Great work.

I had to make only very few configurations to proceed with the install and the installation took less than 15 minutes.

Then i unmounted the live cd from the virtual cd drive and then restarted the virtual machine.

Wow, opensuse booted up quite beautifully and now it asked for some minor configurations like username and password.

Great. My opensuse installation was completed in notime.

And did you know what was the first activity I did after installing it? Blogged about it.

Ya. I'm writing this blog from within the opensuse running on top of my VirtualBox.

Monday, February 18, 2008

MS Virtual PC vs VirutalBox

Working on ubuntu running on top of Microsoft Virtual PC 2007 started giving me lot of problems. Some of them are:
1. Need lots of tweaking during installation of ubuntu in virtual pc to provide even basic mouse integration. Need to enter additional parameters (i8042.noloop) during boot up and then need to configure some system settings to make the mouse work in ubuntu running under virtual pc.
2. No smooth mouse integration. You need to click inside the virtual operating system for the mouse to be effective inside and need to press "Right Alt" key to come out of virtual os.
3. No mouse scrolling support at all.
4. In a nutshell, virtual pc bothers least about linux environments. No addons, nothing.

So, I started looking for alternatives.

I didn't give much focus to VirtualBox until i read the news about Sun's acquisition about VirtualBox. I respect Sun and their products. So i thought of giving VirtualBox a try.

- Installing ubuntu was smooth.
- No need to tweak any boot options like i did while installing ubuntu on top of virtual pc 2007.
- However i needed to press "Right Ctrl" key to come out of virtual box, initially.
- But, once i installed the "add-ons" for linux, i was amazed at the seamless mouse integration. I could click the firefox icon in windows xp and also on ubuntu on virtualbox (to and fro) without pressing any keys.
- I could scroll my mouse like i can scroll on xp.
- Excellent user interface.

However i have some concerns:

- very small resolution size (800 x 600 against my laptop resolution of 1280 x 780)
- need add-ons to provide usb support.

But overall, I feel that virtualbox is much better than Virtual PC 2007.
I regret for spending much time meddling around with Virtual PC 2007.
The fault is with me, I shouldn't have tried a Microsoft product at first place.