Archive for November, 2007

Tomcat 5.5: no JDK found

Wednesday, November 28th, 2007
If you install Tomcat 5.5 (or 5.0) in Ubuntu, you may see Tomcat failing to start because JAVA_HOME is not set:

giannis@giannis-desktop:~$ sudo /etc/init.d/tomcat5.5 start
[sudo] password for giannis:
* no JDK found - please set JAVA_HOME
giannis@giannis-desktop:~$


One way to quickly solve this problem is to edit the file /etc/default/tomcat5.5:

sudo gedit /etc/default/tomcat5.5

Find the section where the JAVA_HOME variable is defined. It should look like this:

# The home directory of the Java development kit (JDK). You need at least
# JDK version 1.4. If JAVA_HOME is not set, some common directories for
# the Sun JDK, various J2SE 1.4 versions, and the free runtimes
# java-gcj-compat-dev and kaffe are tried.
#JAVA_HOME=/usr/lib/jvm/java-6-sun


Uncomment the line that sets the JAVA_HOME variable, and if necessary provide the java runtime environment of your preference. After editing it should look like this one:

# The home directory of the Java development kit (JDK). You need at least
# JDK version 1.4. If JAVA_HOME is not set, some common directories for
# the Sun JDK, various J2SE 1.4 versions, and the free runtimes
# java-gcj-compat-dev and kaffe are tried.
JAVA_HOME=/usr/lib/jvm/java-6-sun


Save the file and try again to start Tomcat, it should be able to start now:

giannis@giannis-desktop:~$ sudo /etc/init.d/tomcat5.5 start
* Starting Tomcat servlet engine tomcat5.5 [ OK ]
giannis@giannis-desktop:~$


Unknown error creating VM (VERR_HOSTIF_INIT_FAILED)

Sunday, November 25th, 2007
If you are getting this error:

Unknown error creating VM (VERR_HOSTIF_INIT_FAILED).
VBox status code: -3100 (VERR_HOSTIF_INIT_FAILED).


while trying to start your VirtualBox on Ubuntu, then it's probably because the user by which VirtualBox is running does not have read/write permissions on /dev/net/tun. To solve the problem run this commands:

sudo chgrp vboxusers /dev/net/tun
sudo chmod 660 /dev/net/tun


then add the user that is going to use VirtualBox to the vboxusers group. Run the following command:

sudo gedit /etc/group

Find the vboxusers group:

...
mysql:x:121:
vboxusers:x:1001:
postfix:x:122:
...


And add all the users that will use VirtualBox into it:

...
mysql:x:121:
vboxusers:x:1001:giannis
postfix:x:122:
...


Save the file and exit gedit. You should not get this error any more.

How to enlarge a VirtualBox disk.

Sunday, November 25th, 2007
This is my success story on enlarging my VirtualBox disk with Windows XP installed, without re-installing anything.

If you want to follow the instructions given here, you will have to get a copy of Ubuntu 7.10 Desktop Edition, because we are going to take advantage of some great pieces of software contained in it.

The whole procedure takes a couple of hours to complete, but the result will be rewarding! So, here we go!

Step 1. Create your new virtual disk

Start VirtualBox and go to File → Virtual Disk Manager. Create a new virtual disk. Make it big enough to meet your needs. At the end, this virtual disk will replace your old one.

new-virtual-disk.jpg



Step 2. Attach the new disk to your virtual machine

Go to your virtual machine's Settings and then go to Hard Disks. Tick the Primary Slave checkbox and select your new virtual disk to be used as primary slave.

add-new-virtual-disk-as-primary-slave.jpg



Step 3. Mount the Ubuntu 7.10 LiveCD

Go to your virtual machine's Settings and the go to CD/DVD-ROM. Tick the Mount CD/DVD Drive checkbox. Select to mount the CD either from your computer's CD/DVD Drive, or from an .iso image file.

mount-cd-dvd-rom.jpg



Step 4. Start Ubuntu

Make sure that your virtual machine will try first to boot from CDROM. Go to Settings → General → Advanced → Boot Order. Make sure that CD/DVD-ROM is checked.

enable-boot-from-cd-dvd-rom.jpg



With the Ubuntu CD mounted start your virtual machine. When the boot menu appears choose the first option, Start or install Ubuntu.

Step 5. Create a clone of your partition on the new virtual disk

When the system comes up, open a terminal window. Go to Application → Accessories → Terminal. When the terminal opens run this command:

sudo fdisk /dev/sda

On the fdisk prompt, type "p" to take a look in the existing partitions of your old virtual disk. Normally you should only be able to see only one. From all the displayed info, we will only keep the End sector of your partition:

ending-sector.jpg



Write it down because we will need it very soon. Type "q" to exit fdisk.

You will now create a partition with the same size in your new disk. Type this command:

sudo fdisk /dev/sdb

Type "n" to create a new partition. When prompted, choose "p" to make it a primary partition, and select 1 as the partition number. Enter 1 (default) as your First cylinder and the number you previously wrote down as the Last cylinder:

fdisk-sdb-new-partition-created.jpg



Then you should set the partition type to be NTFS (that would be the most likely for a Windows XP partition). Type "t" at the fdisk's prompt. When prompted for the Hex code, enter 7 (HPFS/NTFS):

fdisk-sdb-hex-code.jpg



Now, type "w" to write all changes to the disk and exit:

fdisk-sdb-changes-written-to-disk.jpg



Now you have a new partition in your new virtual disk with the exact same size. Now it's time to make a verbatim copy of all the data in your old partition to the new one. Run this command:

sudo dd if=/dev/sda1 of=/dev/sdb1

It will take some time. In fact it will take a lot of time. For my 20GB partition it took almost one hour and a half. So, be patient!

Step 6. Enlarge your new NTFS partition

Now we are going to use GNOME partition editor to enlarge the NTFS partition in the new virtual disk. Go to System → Administration → Partition Editor. Wait until the program scans your devices. Then go to GParted → Devices → /dev/sdb. You should be able to see your newly created NTFS partition and lots of unallocated space following it:

sdb-with-lots-of-free-space.jpg



Right-click on the partition and choose Resize/Move:

drag-to-resize.jpg



Grab the right-arrow of the partition with your mouse, and drag it to the right so it occupies the full capacity of the disk:

use-full-size-for-sdb.jpg



Then click Ok. Click Apply (or go to Edit → Apply All Operations). Seat back whilst the program enlarges your partition. It will take some minutes.

Step 7. Make your new virtual disk bootable

When the resizing is finished the program will scan your devices again. When the scan finishes close the partition editor, and shut down the virtual machine. Go to System → Quit → Restart. You will be prompted to remove the disc and press enter. Unmount the CD (in VirtualBox, go to Devices → Unmount CD/DVD-ROM) and press enter to continue.

The virtual machine will now boot your original Windows XP. Windows will recognize your new parition and will tell that it needs to be scanned for errors. Let windows scan your new partition. It will take some time.

ntfs-check-finished.jpg



When scan finished you will be able to see your new partition under My Computer (it should have been assigned with a driver letter, like E:):

windows-xp-new-big-partition.jpg



Open disk management (right-click on MyComputer → Manage → Storage → Disk Management). Right-click on your new partition and click Mark Partition as Active:

marked-partition-as-asctive.jpg



Step 8. Remove the old virtual disk

Shut down Windows. When the virtual machine is powered-off go once more to your virtual machine's Settings → Hard Disks. Select your new virtual disk as the Primary master, and select no primary slave at all:

new-disk-configuration.jpg



That was all! It wasn't that hard, was it? You should now be able to boot your virtual machine, and find everything in place just as you remember it, except from more free space in your C: drive:

final-screenshot.jpg



I hope this helped...

How to view .CHM files in Ubuntu

Friday, November 16th, 2007
It is easy to open and view Microsoft Compiled HTML Help files (.chm) from Ubuntu. You actually have at least two options: xchm or gnochm.

To install xchm run the following command:

sudo apt-get install xchm

To install gnochm run:

sudo apt-get install gnochm

To view a .chm file using xchm you just have to run:

xchm chm-file

Alternative to open it with gnochm simply run:

gnochm chm-file

Or you you can just double-click on the file's icon.

poor zoom desktop on compiz fusion?

Tuesday, November 13th, 2007
If you just switched from Beryl to Compiz Fusion you may noticed that the cool desktop zoom effects, is a little different from what you have used with Beryl. Specifically you may notice that while in zoom state everything is still.

To fix this is easy. Install this package:

sudo apt-get install compiz-fusion-plugins-main

and then go to CompizConfig settings manager: System -> Preferences -> Advanced Desktop Effects Settings. Then go to Accessibility. You should see a new plugin with the name Enhanced Zoom Desktop. Enable this one and disable Zoom Desktop.

Compiz Fusion settings manager missing?

Tuesday, November 13th, 2007
You have compiz-fusion up and running but can't find settings manager? Install this package:

sudo apt-get install compizconfig-settings-manager

and then go to System -> Preferences -> Advanced Desktop Effects Settings.

loan amortization and interest calculator

Monday, November 12th, 2007
This is an on-line loan amortization and interest calculator I wrote in Java. It is currently available only in greek but I think it is trivial to figure out from the context what's the meaning of each one of these funny words. I hope you'll find it useful!

accessing an SMB remote folder from ubuntu's command line

Monday, November 12th, 2007
You may be able to browse an SMB-shared remote folder using a file browser capable of opening smb URLs like this:

smb://remote-host/folder-name

But if you try to simply chdir into this folder from the unix shell, of course you will get a No such file or directory error, and that's because the shell will not understand the smb:// URL and it will try to handle it like a normal file name.

To access this remote folder from within your shell, you will have to mount it in an existing local folder. That means that you will need root access.

First you have to make sure that you install the smbfs package, to add smb file system support in your system:

sudo apt-get install smbfs

Then you have to create a folder to be used as your mount point:

sudo mkdir /media/my-remote-folder

Then you can go ahead and finally mount the remote folder:

sudo mount -t smbfs //remote-host/folder-name

After that, you can simple go to /media/my-remote-folder and do whatever you want to do from the shell.

aMule crashes upon server list update

Sunday, November 11th, 2007
If you are trying to get (or update) your server list in aMule, you may see the window with the white rabbit jumping here and there, and after a few seconds the whole program is crashing.

Copy and paste this URL in the location text box:

http://www.gruk.org/server.met.gz

Then try to fetch the server list again, it should be working with this one.

mass rename _svn directories to .svn (and vice versa)

Thursday, November 8th, 2007
This is rather useful if you're dealing with both .svn and _svn subversion directories in your projects. (I think only those who use the ASP.NET hack are suffering from this...) Here is described how to recursively rename all of your .svn directories to _svn (or the opposite).

This is the command that you have to run on GNU/Linux:

find project-name -type d -name .svn | gawk '{print "mv \""$0"\" \""substr($0,1,length($0)-4)"_svn\""}' | sh

Of course you will have to replace project-dir with the path where your project lies. If you want to do the opposite (that is, rename all _svn directories to .svn) you just have to switch their positions in the command.

But as I said before mostly Windows users are going to need this, so this is how you do the same thing on Windows XP:

find project-name -type d -name .svn | gawk "{print \"mv \\\"\"$0\"\\\" \\\"\"substr($0,1,length($0)-4)\"_svn\\\"\"}" > rename.bat && rename.bat && del rename.bat

This is a little more obscure but it works. Two things you have to notice are:

1) We make use of two GNU commands, find, gawk and mv, which are not available on Windows XP by default. You will have to install GNU utilities for Win32 which is something you should do anyway if you are seriously using your Windows XP command line.

2) We are using a temporary .bat file that all the mv commands are stored, and then we execute this .bat file in order for the mv commands to actually take place. This is done because there is no shell by default that can receive and execute commands from the standard input.