Saturday, May 31, 2008

Ubuntu 8.04 on Virtual PC 2007

Installing Ubuntu 8.04 on Virtual PC 2007 running on Vista (or others) as a host operating system can be challenging. You may receive an "unrecoverable processor error" in the virtual machine. Here is how to get around it.

I've found this link which provides a very extensive discussion for how to get Ubuntu 8.04 installed on Virtual PC 2007. All the information is there but it may take quite a while until you extract the right bits and pieces. Otherwise it can be quite time consuming to wade through all those "It doesn't work for me either..." comments.

To save your time I want to provide the approach that worked for me. It is an extract or summary of the information given in that discussion. In particular SteveZ's comment and Russ Cain's comments were extremely helpful.

First Time Install

1. Start Virtual PC 2007 (VPC) (Note that Service Pack 1 for VPC2007 has been available since May 15, 2008)

2. Create a new virtual machine with just the defaults. Create a virtual harddisk large enough for the OS (5 GByte) plus all the additional applications you want to install later. I created a 50 GBytes dynamic disk.

3. Mount the Ubuntu 8.04 iso image (700 MB) downloaded from here by using the menu "CD -> Capture ISO Image..."

4. Then reset the virtual machine.

5. Select the language when Ubuntu's installer is displayed.

6. At the prompt, press F4 and select "Safe Graphics Mode"

7. Press F6 and use the arrow keys to position the cursor just behind "quiet splash". Just after "quiet splash" append "noreplace-paravirt vga=791".

8. Select the "Live CD option" (no modifying your system) and boot. You should get into the LiveCD version with an "Install" link on the desktop.

9. Double-click install and follow the on-screen instructions. At the end reboot. If the screen freezes, wait a while and then reset the virtual machine.

After First Reboot

10. When rebooting wait until you see the line regarding the GRUB menu and press the "Esc" key. If you miss that point it is possible that you will see an "unrecoverable processor error" again. In that case, just reset the virtual machine again.

11. In the GRUB menu select "Ubuntu 8.04, kernel 2.6.24-16-generic" and press "e" to edit this boot configuration.

12. Select "kernel /boot/..." from the menu and press "e" again to edit this entry. Just after "quiet splash" append "noreplace-paravirt" and press enter. (Russ Cain suggests to also append "vga=791" and "xforcvesa" but I didn't need this for my system.)

13. Hit Enter, then "b" for booting the system.

14. Log in with your username and password.

Making The Fix Permanent

To make the fix permanent - you probably don't want to go through steps 10 to 14 each time you reboot your system - do the following:

15. After logging in open a terminal window from "Applications" - "Accessories" menu.

16. In the terminal window type "sudo gedit /boot/grub/menu.lst” and press enter. You will be asked for your password.

17. When the editor has started and loaded the file go to the very end of the file, then about 15 lines up. Append "noreplace-paravirt vga=791" to the end of two lines that start with "kernel /boot/vmlinuz-..."

18. Save the file and close gedit.

Now Ubuntu should reboot without complaint.

Please note that during reboot the screen might be blank (black) for quite some time. If you would like to monitor the boot process remove the "quiet splash" option from the kernel line in menu.lst.

Let me know if this recipe was understandable. If not please suggest improvements and make sure you mention the number of the step. Thank you!

Credits

I would like to thank SteveZ and Russ Cain for their excellent advice. This blog entry is based on their input (SteveZ's comment and Russ Cain's comments).

Tuesday, May 20, 2008

Eclipse Europa

It has been a while since I posted on this blog. I had my head very much around other topics such as agile project management and .NET. Those won't go away but it's always good to hone your skills on different platforms just to stay flexible.

Today I installed Eclipse Europa. And I thought I pretend to be a novice user - which I probably am. So I went to the "Workbench User Guide" to get a refresher on the different concepts. As I worked through the guide I noticed that I had to actually click the different pages in the content tree on the left side. It certainly would be helpful if there was a keyboard shortcut, a button or a link that brings you to the next page in the guide. Having to click with the mouse is less conventient.

So far so good. I'll experiment more as I go, and post my findings here. Yes, my Eclipse skills are indeed a little bit rusty...

Monday, September 04, 2006

expression of type X needs unchecked conversion

Ok, so you are using generics in Java but you also work with "legacy" code that has been written without generics. For example, you want to assign a return type ArrayList to a variable of type ArrayList .

Then you might experience a compiler warning similar to the following one:
Type safety: The expression of type List needs unchecked conversion to conform to List
As the compiler tries to statically check the type safety there is no way it can find out whether the raw type list actually contains only instances of YourType.

The solution is to add the following annotation in front of the method for which the warning is reported:
@SuppressWarnings("unchecked")
Note that the generic ArrayList<> is always compiled into the raw type ArrayList. The same applies for all other collections in java.util. The reason is that this type information is removed in order to stay backward compatible. Therefore in Java 5 all instances of ArrayList are mapped to the raw type ArrayList.

For C++ and also for .NET 2.0 and later the designers chose a different solution. In C++ each instance of the template ArrayList is compiled into separate object code. This can lead to code bloat. In .NET 2.0 and later the type information is retained and is available during runtime.

Sunday, August 20, 2006

Iterating Over Enum With Generic Method

Generic methods in Java 5 are nice, but sometimes it's good to have examples to better understand what is going on.

The following generic method iterates over an enum type and retrieves its values (ordinals, i.e. their underlying integer value) and their names:
protected void addType(Class clazz, Enum<?>[] enumValues) {
List<SelectItem> selectItems = new ArrayList<SelectItem>();
for(Enum<?> value : enumValues) {
SelectItem item = new SelectItem(value.ordinal(),
value.name(), value.name());
selectItems.add(item);
}
itemLists.put(clazz, selectItems);
}
The invocation of this method might be:
addType(RoleType.class, RoleType.values());
In this example RoleType is defined as a enum with one or more values.

Another option would have been to declare the method as:
protected <T extends Enum<T>> void addType(Class clazz, T[] enumValues) {...}
However, I decided that the code would look harder to read, so I used the wildcard version instead. Let me know if this example was helpful.

Monday, August 14, 2006

I've Moved

I moved over my Java blog from JRoller. That way it's easier to maintain the various blogs I have. So for my older posts on Java, please see my old Java blog.