Using PowerISO to overcome major missing feature in VirtualBox

Sun VirtualboxOne of the great things about modern computers is that they have multiple cores and gigabytes of memory. This means that it is practical to run multiple operating systems on one machine using virtual machines (VMs). There are a raft of VM products available for desktop PCs. The best by far in my view is VMware Workstation. It however has one big problem: it costs $189, whereas there are many good-enough products that are free. So my VM product of choice – after trying many of them – is Sun’s xVM VirtualBox.

Whilst it serves its purpose the vast majority of the time, I recently came across a fundamental problem with it: it doesn’t support shared folders, or copying files, when the “guest” (VM) is Solaris. It is possible to copy files from a Solaris box to a Windows or Linux guest; from a Windows box to a Linux guest etc, but Solaris guests cannot do this. A search for solutions yielded various complicated ways of mounting/ unmounting USB drives or setting up Samba and the like to share files over the network. There seemed to be no simple way around the problem though.  I have hit upon what I feel is a fairly simple work-around myself, so I’m sharing it with others here.

The solution I used for getting files from Windows onto the Solaris guest may surprise people: I used ISO images. However it doesn’t involve burning real CDs/ DVDs; just creating .iso files. To do this, I used a program called PowerISO. The free version will create images up to 300Mb, so it’s likely to be usable in many situations. There are other programs capable of creating ISO’s too if you prefer to use them, but I like PowerISO (I bought the full product), so I’m describing that here.

The steps to transferring files from Windows to Solaris are:

  1. Open PowerISO and a Windows Explorer window.
  2. Navigate to the required files in Explorer and drag them to PowerISO
  3. Go to File menu -> Image Properties in PowerISO and turn off “Enable file optimization” (this’ll save lots of time in the next step)
  4. Save to an ISO file. I found 200Mb took around 10 seconds to save on a 5400 RPM laptop disk.
  5. Now switch to Solaris guest and select Devices menu -> Mount CD/ DVD-ROM
  6. Add your ISO image to the list and mount it.
  7. A File Browser window will open up in Solaris. Copy the files from there to where you want them on the Solaris file system

And that’s it: job done. To then transfer more files:

  1. Eject the “CD” on Solaris
  2. Select Devices -> Unmount CD/ DVD-ROM from the menu
  3. Now delete the files from PowerISO, drag some new ones across and save again. Say yes when prompted whether to overwrite them.
  4. Repeat steps 5 and 7 above

UPDATE

No sooner did I write this post than the Sun VirtualBox team let me know via twitter that a new version of VirtualBox is due in a few weeks, that will fix this problem. This is great news, even though it renders my work-around unnecessary almost as soon as I find it 🙂

Is it time to retire Java?

DukeYesterday, the boss and I took a trip up to London for Sun’s UK Developer Update event at the Royal Geographical Society. There was a “keynote” by James Gosling, followed by presentations on JavaFX, Java EE 6 and details of what is likely to be in Java SE 7.

Now I should make it clear that until recently, I regarded myself as a C# and ActionScript programmer. I’m new to Java. This isn’t strictly true, as I used Java back in its Java 1.1 days, but its changed so much since those days (and I’d forgotten most of it anyway), that in practice I’m a Java newbie. As a result, I naturally judge Java against C# (and to a far lesser extent, against ActionScript).

C# owes its existence to Java. Languages prior to Java may have had garbage collection, reference types rather than pointers, bytecodes, just-in-time compilation etc, but Java bought these technologies into the mainstream. As it came after Java, C# was able to adopt all the good points of Java, and scrap the bad stuff (the getter and setter mess of Java is replaced with elegant properties for example). Whether it did this successfully or not is a matter of opinion of course. From my point of therefore, Java automatically deserves respect, but it doesn’t deserve automatic authority. People grow old and wise, but also grow set in their ways. Programming languages appear to do the same.

Despite its seniority, Java has some clear advantages over C#. Breaking to labels is a glaring omission in C#, which Java has. C# requires the use of the evil-incarnate “goto” to simulate breaking to labels. Also the XML mess that is documentation comments in C# is pure farce compared with the simple elegance of Javadoc. Java has a whole raft of deficiencies though, and the two biggest ones are the lack of anonymous functions (let alone closures) and the lack of properties. Both have been proposed for Java 7, but – according to Sun’s presentation yesterday – neither will now appear. On a lesser note, Java 7 will not support operator overloading either, so string comparisons will remain using the grossly messy .equals() method to compare string value. This is a minor issue in comparison with properties and closures.

Why are anonymous functions/ closures and properties such a big deal? Both can be worked around in Java. Properties are after all just a neater way of doing getters and setters and people have come up with bodge simulations of delegates for Java. The big deal is that these are basic features of modern languages. Even the somewhat “noddy” scripting language, ActionScript, manages to implement both. Every other JVM-based language that I know of – JRuby, Jython, Groovy and Scala – all support closures.

Java is old and is becoming set in its ways. Language developers always run into problems with balancing feature advancements with avoiding breaking legacy code and Java is no exception. Perhaps we need to accept that closures and properties will never come to Java as it is just too difficult to implement both neatly, without breaking backward compatibility in too big a way. If this is the case, then perhaps Java 7 should be the last version of Java and it ought to be retired and replaced with a younger, more adaptable language.Whether the growth in alternative JVM languages is a sign that people are already moving on from Java to newer languages is difficult to judge. JRuby, Jython, Groovy and Scala are all dynamic languages. Dynamic languages have seen a general resurgence in popularity recently. What is needed though is a static language replacement to Java. One that can seamlessly interact with legacy Java code, whilst supporting modern programming principles such as closures, operator overloading, properties etc, along with support for dynamic types (without being inherently dynamic), functional language principals such as currying and lambda expressions.

The more astute of you may spot where I’m heading here. Just as C# was born of Java, so perhaps we need a new version of Java, born of C#. Being a English tea addict, who is pretty indifferent to coffee, I propose (not very seriously) that we call it Lapsang. C# itself is starting to get old, and many of the new features – such as extension methods – have been implemented in an inelegant manner to avoid the backward compatibility issues that new keywords bring. So just as C# took Java’s good bits and added more of its own, Lapsang could take C#’s good bits, add a few new bits of its own (build concurrency into the core of the language for example) and give the JVM another 10+ years of life.

Java proberly is a dying language and it risks taking the JVM with it. If Sun (or IBM perhaps, if they buy Sun) bite the bullet and retire it as the prime JVM language, then there is no reason why the JVM cannot thrive and grow for many more years.

How to use third party image editors from within Picasa

Google Picasa logo

Google’s Picasa is a pretty good photo management tool. It’s free for a start and it offers a decent feature set, including the ability to geo-tag pictures and have them appear in Google Earth. However, one aspect of it is utterly bizarre: the way in which it integrates with other programs. I don’t know about you, but the normal way I’d expect a program to integrate with 3rd party tools would either be via preferences, or via a simple, easy to edit, configuration file. I’d expect to specify the path to the application and maybe supply a PNG if the program supported some sort of toolbar.

Picasa takes a very different approach to 3rd party application integration. To make Picasa aware of a 3rd party tool, one must create a zip file which contains an XML file that defines the buttons behaviour, and a Photoshop file that defines the button’s appearance. To then make Picasa aware of this file, one needs to deliver it via a web link or by entering a complex URL into a web browser. Google have produced a button API, which describes the process of adding a new button fairly well. As I discovered though, there are some “gotchas” to be aware of. I use Paint Shop Pro (PSP) as my image editing tool of choice. Also, as I have a Sony Alpha digital SLR camera, I use Sony’s RAW image editor to process the photos I take. I wanted Picasa to therefore support both of these programs.

PSP Button ImageI started by creating a .pbz (the zip file) for Paint Shop Pro. I followed the API’s advice and used a GUID to give my .pbf (the XML file) and .psd (the Photoshop image) unique names. As Paint Shop Pro doesn’t store its executable location in the registery, I hard-coded the path and ended up with the following XML:

If you refer to the API documentation, you’ll see that I’ve defined a new button that will save any edits to the selected images and a make a copy of those images. It then launches PSP, and passes the set of temporary files to that application. Also the file defines the inelegantly named – but statistically unique – {68bd7eb6-3ad1-4036-92f0-8c896a754a75}.psd, which contains the button’s image.

Next, I used PSP to create the Photoshop image for the button, zipped it all up and FTP’ed it to my blog’s server and created a test page with the appropriate link in it. I loaded up the test page, clicked on the link, watched Picasa launch and ask me if I wanted to import the buttons. Then the disappointment set in, as the button’s text was all displayed correctly, but it had no image. I checked and rechecked everything, tinkered with PSP’s settings and tried again and again, but to no avail. I couldn’t get an image to appear. I happen to have a trial copy of Adobe Fireworks on my machine at the moment though, so I tried editing the Photoshop image I’d created in that. The layer’s name appeared quite different to what I’d set it as in PSP. So I fixed it, saved it and tried again. The image appeared on the button just fine.

This left me irritated with both Corel and Google. First of all with Corel: why support the saving to file formats like Photoshop if you aren’t going to implement it properly? And with Google: there are well-supported, open, image formats such as PNG that they could have used. So why did they choose a proprietary file format (especially as it’s not even their own proprietary file format!)?

sony-raw-buttonHaving overcome the image problem with my PSP button, I expected the Sony RAW tool to be fairly straightforward, and it almost was. The tool appears in the registry, so I was able to use that path, rather than hard-coding a file path as I’d done with PSP. Aside from that, I copied the XML file, changed the wording and tried using it. It installed correctly, with the correct image (courtesy of Fireworks). However, when I then selected an image and clicked in the new button, the tool complained that it was being given a JPEG file. This is fairly useless for a RAW image editing tool!

All was not lost though. After some experimentation, I removed the export tag from the file and it sprang into life. I had missed the fact that it doesn’t just create temporary copies of the images, it creates temporary JPEG images, regardless of the original file type. So the final XML for my Sony RAW button was:

At the end of the process, I now have my two buttons working well. Getting there was a painful process, but hopefully this post will save others time in creating their own buttons.

If you want to use either button in Picasa, click on the Paint Shop Pro X2 installer or on the Sony Image Data Converter SR installer links to import them into Picasa.

Alternatively, you can download the button zip files for Paint Shop Pro X2 and Sony Image Data Converter SR here.

UAC goes from crap to worse with Windows 7

Windows 7In my view, UAC on Vista is a useless waste of space. It is annoying, can be compromised and the only sensible option for a developer using it, is to turn it off.

Enter Windows 7, with its promise of an improved UAC. From my perspective, it is still as broken as ever. I created a folder in Program Files and suffered a barrage of UAC dialogues as it created and renamed the folder. So I promptly turned it off again. However it has left me wondering whether I was hasty. How were others faring with it? If Peter Bright’s analysis is anything to go by, it looks like the claims of improvements are less than honest.

Microsoft made a huge mistake with UAC. It was the wrong solution to a very real problem. They should just have admitted they got it wrong, scrapped it and tried a new a approach with Windows 7. Instead, they seem to feel that they can turn a pig’s ear into a silk purse by sowing an ass’ ear to the side of it. UAC seems to stand for Unwanted Assinine Cludge these days. It’s a great shame, as they seem to have addressed most of the other annoyances of Vista with WIndows 7. So why couldn’t they have fixed UAC properly too?

Internet Explorer will be an optional component in Windows 7

Windows 7It is being reported by those with build 7048 of Windows 7 that IE8 appears in the “Turn Windows features on or off” control panel dialogue. Disabling it – and rebooting twice apparently – then removes explore.exe from the system. It appears that programs that embed the IE activeX within themselves will still work (which is a good thing).

IE8 appears in "add/ remove windows components" in Windows 7. Image copied from <a href=
IE8 appears in "add/ remove windows components" in Windows 7. Image copied from Neowin.net

The big question is: what happens to all those crappy programs that ignore the user’s default browser settings and just launch IE when handling a link? Will they crash? Fail to do anything? Or will Windows 8 intelligently re-route such calls to the default browser? Hopefully it will be the last option, but I guess time will tell.