Part Three – Configuring Ubuntu to use your newly installed Java JRE and SDK
There are a lot of technical steps in this part, and I figured them out mostly through heavy internet searching, piecing together information from other blogs, and trial and error. The main issues were caused by every site expecting you to already have some key components installed before trying to get this working. So when I tried to follow their guides they never worked. That is why we are here now, using a fresh and clean Ubuntu installation.
updated for Java 7 on February 8th 2012
- cd /opt/java && sudo ln -s /opt/java/jdk1.7.0_02 /opt/java/jdk-linked && sudo ln -s /opt/java/jdk1.7.0_02/jre /opt/java/jre-linked – this moves back to the /opt/java directory and creates a link to the jdk folder that we can use to reference to later, that way if we ever install a newer version of java all you have to do is remove the links and create new ones, not have to go through this whole process again! you can test by typing cd jdk-linked && ls – and you will see the contents of /opt/java/jdk1.7.0_02 (don’t forget you can use [tab])
- sudo update-alternatives –install “/usr/bin/java” java “/opt/java/jre-linked/bin/java” 10 && sudo update-alternatives –set java /opt/java/jre-linked/bin/java – this updates Ubuntu so it can find your new jre and makes it the default jre to be used by the system (again future proofed because we used the linked location)
- if you want to, we can setup java for Firefox too
- mkdir ~/.mozilla/plugins/ && ln -s /opt/java/jre-linked/lib/i386/libnpjp2.so ~/.mozilla/plugins
- cd && vi .profile
- [ctrl+f]
- [o]
- EXPORT JAVA_HOME=/opt/java/jdk-linked
- [enter]
- EXPORT PATH=$PATH:$JAVA_HOME:$JAVA_HOME/bin
- [esc]
- :wq!
- now we need to repeat the next set of instruction with the following items placed in [java] (everytime you see [java] put one of the following until you have done these steps for each of the following), I have noted after each one if you need a jre or jdk, or both lines for it, if both, replace the 10 with a 5 on the jdk (this will add both the jre and the jdk alternatives to the list making the jre ones the default). Or, just use this script. (remember to look at the script first to make sure it does what I said, and to set it as executable! cat java-update|more && chmod +x java-update then execute it with sudo ./java-update)
- java – jre/jdk
- jar – jdk
- jarsigner – jdk javac – jdk
- javadoc – jdk
- javah – jdk
- native2ascii – jdk
- rmic – jdk
- rmid – jre/jdk
- rmiregistry – jre/jdk
- serialver – jdk
- sudo update-alternatives –install “/usr/bin/[java]” [java] “/opt/java/jre-linked/bin/[java]” 10
- sudo update-alternatives –set [java] /opt/java/jre-linked/bin/[java]
- mkdir ~/source-build && cd ~/source-build && sudo apt-get install debhelper gcj-4.4-base gcj-jdk m4 debiandoc-sgml python-docutils cdbs – moving on, we need to install some things before the adding Titanium to the system, this group (plus their dependencies, you don’t want to know what I went through to get this list exactly correct, it took a couple of months the first time I worked on getting this installed) takes up 823MB and took me 16 minutes to download and 2.5 minutes to install. as an fyi, I figured these out by not having them installed the first time around and spent weeks trying to figure each part out, because these files are not what causes the failed instal, linux will pull the dependencies for you when you install something, but there are dependencies of dependencies of dependencies… and somewhere down that line linux fails to grab the final set! So you need to install them in this order, I then spent another week or 2 finding out that those in particular have to be installed before the next set or the next set fails to install!
- sudo rm /var/lib/apt/lists/* && sudo apt-get update – this will resolve an issue with the sources of the next step
- sudo apt-get install llvm-gcc-4.5 && sudo apt-get build-dep llvm-gcc-4.5 && sudo apt-get -b source python-defaults ruby-defaults && sudo apt-get update && sudo apt-get dselect-upgrade && sudo apt-get autoremove – this set downloads the source files for each of these and builds them specifically for your system and then cleans itself up, this did prompt me for 62.5MB of additional storage space and the build process took about 20 to 45 seconds on my machine.
- sudo apt-get install ispell – I have found a few other things that are necessary for titanium to work
- restart your development VM
- mount your shared drives and take a new snapshot after the system comes back up, called pre Android SDK, and comments “OS, java jre&jdk, and compilers installed”
maybe you don’t really need all of this, but I don’t want to find out while I am writing my Android app that I missed a step, as then you won’t be able to re-use the snapshots in case of an emergency (also called a mistake!). One other note, if you noticed I made a new directory and used it for the source builds, this is because at least the python source build requires several chown commands to run and if you try to execute them on a VM share mount it will fail and you cannot complete the build. Congratulations! I know this was a tough part to do, and I’ll have to check it over sometime in the future to recreate the entire process step by step and make sure it all works again (never know where there might be a typo!). Next time we meet it will be to install the Android SDK and Titanium. After that we will build a short crappy Android app to test everything and then make an .iso Live CD of the whole VM! The final file was pretty big, I’m not sure if a Live DVD would cover it all! I’ll test this idea and add it to the final post if it works. I will be heading out of town for a couple of days so don’t expect anything before monday!
again, after I finish this series up, I’ll add in resource links
Due to the popularity of my Fedora 12 version of this how to, I have copied it here and made the necessary changes for (K)Ubuntu 10.04 Guests (I actually did this while making said changes so I know it works…) :)
step by step instructions for getting shared folders to work in a Kubuntu 10.04 VM on VirtualBox (post OS installation)
- open a console window (I am a huge fan of Yakuake)
- sudo apt-get update
- sudo apt-get dselect-upgrade
- sudo apt-get install gcc gcc+ linux-kernel-headers
- restart the VM to boot with the newest kernel
- sudo apt-get autoremove (this will remove the old kernel files and decrease your used space on the virtual drive)
- goto the Devices drop down menu for VirtualBox and select install Guest additions
- sudo mount /cdrom /media
- sudo /media/VBoxLinuxAdditions-x86.run
- You will need to reboot the VM to reinitialize the HAL daemon (or manually restart the daemon if you know how; however restarting will let (K)Ubuntu auto resize your display as well)
- (special note, if you have already run the VBox Additions from the cd and just need to update it, or it was not working, then skip steps 7-10 and just type this “sudo /etc/init.d/vboxadd setup“
- sudo mkdir /mnt/[name you want your shared folder to have in the VM]
- mount -t vboxsf [name you gave the share in VBox] /mnt/[name you used in step 12]
- then you can now access your shared host directory from your (K)Ubuntu 10.04 install in the /mnt/[name you used in step 12] folder!!!
Really not that hard, but nowhere in the documentation for VirtualBox does it tell you that you have to do all of that!
Bonus step!!
now I bet you want to know how to make it comeback after a reboot, don’t cha!
- sudo vi /etc/fstab
- “G” (uppercase letter)
- “o” (lowercase number)
- [name you used in VBox shared folders] [tab] [fullpath to the mount point in the VM, or #12 above] [tab] vboxsf [tab] noauto,rw [tab] 0 [tab] 0 (both of those are the number zero)
- [esc] (the escape key, probably is labeled “esc” on your keyboard in the top left corner)
- “wq!” (lowercase letters and an exclamation (sometimes called a “BANG” by unix people, older people, and those who were taught by one of the afore mentioned.))
- now reboot
- sudo mount [name you used in VBox shared folders] (you will have to do this everytime you reboot (I just do a save state, so not an issue very often) as the fstab loads the mounts BEFORE the VBox additions are run, causing a “not found” error if it is not setup this way)
Special note: the folder name from VirtualBox shared folders is normally the name of the last directory in the path, for example if you are sharing /home/[my username]/Downloads/mystuff – then your VBox shared name will be “mystuff”
Also, check out my post on getting this to work in Fedora 12!!
Twitter: finndo77
- New blog post... Diablo III closed Beta http://t.co/dKC2ChWm 01:36:32 PM December 07, 2011 from joelperryproductions.com ReplyRetweetFavorite
- New blog post... resolving video problems with K-L-Ubuntu and XFX Radeon 6850 http://t.co/H6bXuMqi 06:59:18 AM October 22, 2011 from joelperryproductions.com ReplyRetweetFavorite
- New blog post... Computer upgrades http://t.co/6PWVNy4m 01:39:35 PM October 20, 2011 from joelperryproductions.com ReplyRetweetFavorite
- $7 for $15 Worth of Hand-Tossed Pizza, Calzones, and Drinks at Andolini's Pizza Charleston, SC http://t.co/QnKwPwB 11:49:26 AM August 29, 2011 from Tweet Button ReplyRetweetFavorite
- New blog post... is zdnet.com/news down http://t.co/DThuI4r 07:57:28 AM August 17, 2011 from joelperryproductions.com ReplyRetweetFavorite
- New blog post... Netflix Down? http://bit.ly/q74Svu 07:39:30 PM August 08, 2011 from joelperryproductions.com ReplyRetweetFavorite
Blogroll
programming
Tech Websites
- a good coder I found on CodeProject
- Barebones HTML coding chart
- Code Project
- Extreme Overclocking
- FreeBSD blog
- Legit Reviews – Tech Hardware Review
- Linuxtopia
- Notion Ink – homepage
- Plug Computing web site and forums
- Tablet Roms – used to be – Notion Ink Hacks
- Ubuntu Forums post on the mount command and fstab file
- VMWare ESX blogger
- Wikipedia.org main page
- ZDNet's blog pages

