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.
- cd /opt/java && sudo ln -s /opt/java/jdk1.6.0_21 /opt/java/jdk-linked && sudo ln -s /opt/java/jre1.6.0_24 /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.6.0_21 (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 ~/sourcebuild && 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 not prompt me for the additional storage space until it got to the apt-get dselect upgrade step (some 48kb) but 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
As a follow-up to my most popular post ever, installing KUbuntu 10.04 32-bit on VirtualBox and Appcelerator’s Titanium Mobile Developer, I am going to do another version for Ubuntu 10.10 32-bit running on VMware workstation 7.1.3. the installation process is mostly the same on VirtualBox, you [...]
As a follow-up to my most popular post ever, installing KUbuntu 10.04 32-bit on VirtualBox and Appcelerator’s Titanium Mobile Developer, I am going to do another version for Ubuntu 10.10 32-bit running on VMware workstation 7.1.3. the installation process is mostly the same on VirtualBox, you will just have to follow a different method for setting up shared folders (you can use my previous post for that). Several things have changed in the last year and I haven’t done 10 minutes of development work, not to mention I am not even sure where the files for the 10.04 VM are! (update, I found them, but they failed to boot, might be the 600 freaking virtualbox updates since then!!) This has taken me 6 days to write up, I’m almost, but not quite done, AND it is close to 3000 words at this point, so I am going to post it in three four parts, so in any case let’s get started.
**anything in bold is either a heading or a command for you to type into a terminal window! (heading should also be underlined)
Part one – setting up Ubuntu 10.10 32-bit
(this is hoping you already have VMware workstation installed on your system, as I am not going to go through that process again! it was a nightmare and took weeks to get going on my current system. As background I am running Ubuntu (not KUbuntu like last time) 10.10 x64 as my host machine, and Ubuntu 10.10 32-bit as the guest. I am installing all of the development files on the VM, because the first time I tried setting Appcelerator’s Titanium on my host machine, I had to format and reinstall the OS, now I have learned the power of home virtualization and run almost everything through it instead of on my actual desktop. The most important thing I have learned is only assign 1 cpu core to any VM until you find it runs at 100% when you perform tasks within it, then increase the number of cores by 1, the second most important thing I have learned using virtual machines is to never install a 64-bit OS, things are just easier to do with a 32-bit OS. (currently the only computer in my house running windows is my work laptop and I’d change that if I didn’t think it would get me fired!)
- have a working operating system
- install VMware workstation
- download ubuntu 10.10 32-bit and use the automatically install VM guest tools options to simplify
- I recommend naming the vm something useful, like android-dev, or titanium-mobile
- then set the host name the same
- make the Virtual HDD at least 20GB (I made mine 38GB and we shall see if that is satisfactory over time…)
- after testing with the kitchen sink I have not seen the RAM usage go over 450MB, so let’s assign 768MB of ram at this time
- go ahead and set 1 CPU with 2 cores, as having the Android Emulator running will peg 1 core at 100% all the time
- follow-up by setting the account password the same as the VM name, so if you don’t use it for 6 months after setting it up, you’ll still be able to log in
- next you need to setup shared folders in the VM, this is where we will store all of your work (on the host machine, incase something happens to the vm, you can always just wipe it and build another without losing your dev files.
- use the VMware workstation pull-down menu VM –> settings
- go to the options tab
- click shared folders
- select enabled
- add
- you should put what ever location you save your downloads to here, so you can get files from your host, then open them in the VM, I named this one “downloads”
- add a second shared folder, this one is where you want to keep your development environment, in case you need to reinstall Titanium on another machine later, I named this one “projects”
- log into the new Ubuntu VM and let’s change some settings
- (you might not have to do this, but I did) go to the System pull-down menu –> preferences –> monitors and change the resolution to something more appealing than 800×600, make sure it is at least 1280×900 or you won’t be able to create a UVGA854 display android VM (even that might not be enough, but it is just enough for a WXVGA800 AVD)
- click make default, enter your password, then close all of those windows
- go to the Applications pull-down menu –> accessories –> terminal
- sudo apt-get update |sudo apt-get install dpkg dpkg-dev |sudo apt-get dselect-upgrade
- now, while that runs, let’s do some other things, go to the System pull-down menu –> preferences –> screen saver
- uncheck Activate screensaver when computer is idle and uncheck lock screen when screensaver is active
- click power management at the bottom and set display to never
- click make default, enter your password, then close all of those windows
- go to the system pull-down menu –> administration –> login screen and click “unlock” enter your password, and set it to log in automatically, then close all of those windows
- in the top right hand corner of the VM desktop click the power button (should be red) and select Restart to complete Update
- now open up your terminal again (if you closed it)
- sudo apt-get autoremove
- the bad news is that you have to reinstall VMware tools, because you now have a new kernel
- go to the VMware pull-down menu VM –> reinstall VMware tools
- click ok on the popup
- the CD should auto-mount and open in a new window
- if not go to the Ubuntu Guest pull-down menu Places –>Computer
- on the left column go to File System –> /mnt –> open the VMware guest additions
- double click on the tar.gz file
- right click the folder vmware-tools-distrib
- select extract to…
- Put it in your downloads folder
- when it finishes, close all of these windows and go back to your terminal window
- navigate in the terminal to the vmware tools folder cd~/Downloads/vmware-tools-distrib
- sudo ./vmware-install.pl
- type yes to over-write the current installation
- press enter 10 times (when prompted!) to select the default installation locations (you will notice the script builds the tools from the source, which is nice), when it finishes, move on to the next step
- sudo vi /etc/fstab
- [Ctrl+f] – this should move the cursor to the last line
- o – this should insert a blank line at the end of the file and begin editing mode, copy and paste the following section and edit to fit the names you used or an alternate location if you don’t like mine.
- [Esc]
- : wq!
- [enter] – this will (in order) exit edit mode, save and quit the vi editor
- mkdir ~/android – you have to have an existing directory or the mount will fail!
- go to the power button in the top left corner of the guest screen (notice that it is grey this time, not red as there is not an update restart required)
**note – it would appear that the vmware guest tools do not install and mount the shares before the mounting process for the OS (which makes sense if you think about it), this means every time you restart this VM you will have to type “s” twice to skip the failed mounting of these two bind mounts. an inconvenience, but remembering to type sudo mount -a is a lot easier than almost anything else you could do as an alternative, only because mount requires super user rights and during the login process you cannot respond to a prompt for your password.
- goto the VMware workstation pull-down menu VM –> Snapshot –>Take Snapshot
- change the snapshot name to: pre-java install
- put the description as: OS installed, configured, updated, restarted, VMware tools reinstalled for new kernel, restarted again. ready for Java SDK installation
- click ok to start the snapshot
/mnt/hgfs/downloads /home/sdk/Downloads none bind,rw,user,auto,exec 0 0
/mnt/hgfs/projects /home/sdk/android none bind,rw,user,auto,exec 0 0
Ok, this is the end of part one, here we have installed our Ubuntu 10.10 32-bit OS, updated it and created a snapshot so we have a quick easy back-out in case anything screws up during the java setup (this has happened to me more than once in the past!). Before continuing on, go to your home folder and make sure the 2 shared folders show up where you put them! else this next part might not be very pretty for you…
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!!
ok, so I woke up and now can’t get back to sleep. nothing new, but this time I decided to do something instead of just laying there hoping to fall asleep before the sun rises. Now, I thought that I already had this working, but apparently not… —edit okay, so I need to note I was doing these steps while writing this post and when I got to the step to reboot Fedora, step 6, I fell asleep.
I was and am currently using, a Fedora 12 VM from my laptop, now I thought I had the shared folders from the host OS (Win XP) setup, but could not find the mount point, so I just attempted to re-mount it. fyi I’m using VirtualBox 3.1.2 so I attempted to remount the shared folder to a simple location…
$ sudo mount -t vboxsf documents /home/finndo/Documents/local
mount: unknown filesystem type ‘vboxsf’
so I do some Googling and come up with some interesting tidbits…
so, if you didn’t look at the link, here it is in a nutshell, to get the mount to work (yes I installed the VM additions, but did not notice the error…) please read the whole post before trying this, as there are some steps you may need to do a little differently and I have noted this, but not until after I list them!
ok, let me start from the beginning…
step by step instructions for getting shared folders to work in a Fedora 12 VM on VirtualBox (after you get fedora installed)
- open a console window (I am a huge fan of Yakuake)
- type “sudo yum install system-config-display”
- give it your password (you may have to do this every time you type sudo)
- type “sudo system-config-display”
- this will open a window in your GUI (KDE, Gnome, XFCE, ICE, whatever) choose the options for your display (if using Yakuake you need to hit F12 to make the console window go away so you can see this new window)
- type “sudo yum install gcc kernel kernel-devel kernel-headers”
- restart the VM to boot with the newest kernel
- goto the Devices menu and select install Guest additions
- back to the console and type “sudo mount /cdrom /media”
- type “sudo /media/VBoxLinuxAdditions-x86.run”
- (special note, if you have already run the VBox Additions from the cd, skip steps 7-10 and just type this “sudo /etc/init.d/vboxadd setup”
- now I do not remember if I had to create the share for My Documents in VirtualBox or if it was there by default, but I have one, called “documents” and that is the one I am using in this example. so, type the following “sudo mkdir /mnt/shared-docs”
- type “mount -t vboxsf documents /mnt/shared-docs”
- then you can now access your Windows XP My Documents folder from your Fedora 12 install in the /mnt/shared-docs folder!!!
Really not that hard, but nowhere in the documentation for VirtualBox does it tell you that you have to do all of that!
Now, you can type “su -” and give it your password, then you do not have to use “sudo” at all for the entire process. you may ask why I do it then, and it is because I work on linux and unix systems for a living (or at least I am trying to) and for security reasons they tell you to never su to root (become the root user) as it is too easy to type an accidentally command in that will make the entire system irreversibly broken (with out restoring from a backup) and since I have been logged into some servers that are used in the monitoring/maintenance of the space shuttle and international space station, so making one of those stop working for several hours or more is a really bad idea! therefore you sudo every command you need to run as root instead of becoming root, gets annoying at times, but almost eliminates the chance of accidental termination of your employment!
Ok, so a note, I am running this Fedora 12 VM on a single core laptop with 2GB of Ram (1.5GB given to Fedora, and nothing running in the host except the VM) and when I ran step 5 step 6 (I added a step later), it practically halted my system and took almost 30 minutes (part of the reason why I fell asleep) it would say it was downloading a 8.6 meg file and take 14 minutes to do so, at 858Mb/s (which is impossible I know, but that is what it did and said) anyway, the main reason I did this, is that I had downloaded some other Fedora .iso files and filled my Virtual HDD and needed to get them off!!
So, now you know… and as we all know… Knowing is half the battle!
************editing updates and bonus steps! *********** May 10th 2010 ****************
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”
***note
you can now visit my Ubuntu 10.04, VirtualBox, and shared folders – a how to
[finndo@fedora12KDE yum.repos.d]$ sudo mount -t vboxsf documents /home/finndo/Documents/localmount: unknown filesystem type ‘vboxsf[finndo@fedora12KDE yum.repos.d]$ sudo mount -t vboxsf documents /home/finndo/Documents/localmount: unknown filesystem type ‘vboxsf’
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



