Mastodon

Missing images in JavaFX on Ubuntu Karmic

Last weekend was spent installing Ubuntu Karmic on my laptop. Because of all the programming stuff I am working on it just made sense even though I am already missing a few of my favourite Windows programs. As soon as I got Netbeans set up I tried running a JavaFX application I had been working on. The stage icons and the images I had loaded in were nowhere to be seen. I gave this a few days to percolate and sat down this evening to sort it out. I started out thinking that it might be a problem with the file paths being different on *nix but a little experimentation showed that paths were not the problem. It took a little reading before I got a reminder; Sun is not the default JVM on Ubuntu! Grrrr.

After switching to Sun Java away from Open-JDK all my images and stage icons were loading happily and my JavaFX app runs just like it did on Windows. Here is the command:

mike@sleepycat:~$ sudo update-alternatives –config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                      Priority   Status
————————————————————
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java to provide /usr/bin/java (java) in manual mode.

Connecting to a web server on a VirtualBox guest.

One of the things I did frequently when using VMware is connect from my host (usually Windows) to my guest (usually Linux). The fact that I don’t really remember how I set that up seems to indicate that it was pretty trivial or just worked “out of the box” (which is a funny thing to say about a VM). After happily using Virtualbox for a while now, the need to connect from host to guest has inevitably reared its head and I was a little surprised that there does not seem to be a straight forward way to do that. Turning as one usually does in such a situation, to Google, and since it was a bit of a fiddle I thought I would scrawl it down here.

The Windows version:

Open the Windows command line and navigate to

C:\Program Files\Sun\VirtualBox>

There are three commands that need to be issued. The command is a little daunting at first glance so here are the important parts:

“karmic” is the name I gave my VM when I created it.

“pcnet” refers to the PCNet virtual network card that I am using in my VM which you can select in your network settings. e1000 is also valid if thats what you’re using.

“railsdev” is the name that will be given to the port forwarding configuration that these commands set up.

The rest should be fairly self explanatory:

C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/Protocol” TCP

C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/GuestPort” 3000

C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/HostPort” 3000

On *nix things are roughly the same, except that the default network card is the Intel Pro/1000 instead of the pcnet you can see above. Consequently you will need to do something like this:

vboxmanage setextradata “mavrick_server” “VBoxInternal/Devices/e1000/0/LUN#0/Config/rails/Protocol” TCP
vboxmanage setextradata “mavrick_server” “VBoxInternal/Devices/e1000/0/LUN#0/Config/rails/GuestPort” 80
vboxmanage setextradata “mavrick_server” “VBoxInternal/Devices/e1000/0/LUN#0/Config/rails/HostPort” 8080

You can see that here I am forwarding port 8080 on the host to port 80 on the guest and naming the forwarding configuration “rails”. Also notice the “e1000” that identifies the network card. Other things to note are that the quotes around the VM name (“mavrick_server” in the above example) MUST be there and they must be regular quotes not angled ones like  “ or ”. Angled quotes will be assumed to be part of the machine name and throw an error like this:

ERROR: Could not find a registered machine named ‘“webserver”’

Replace the quotes with proper ones and you should be good.

Happy forwarding!