Wednesday, December 31, 2014

How to Install Oracle Java and Android Studio on Mint 17.1

This article is a 'how-to' for installing Oracle's Java JDK 8 (or SE 8) and Google's Android Studio on Linux Mint 17.1 (Rebecca). If you wish to develop software on the Android platform on your Mint 17.1 PC, then this 'how-to' is for you. Note that most necessary steps are performed at the command line in a terminal - if you are not familiar with this, I suggest reading about it first before trying out this 'how-to'.

On a newly-installed and updated Linux Mint 17.1, only OpenJDK JRE (Java Runtime Environment) 7 is installed by default. This can be verified by executing the following in a terminal:

  java -version

The output is as follows:

  java version "1.7.0_65"
  OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1)
  OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)


Although whether the JRE or JDK version of OpenJDK 7 is installed by default is not clearly indicated in the output, it can be easily verified by executing the following:

  update-alternatives --list java

The output is as follows:

  /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

This clearly indicate that only the JRE is installed by default. Google's Android Studio requires the full Java JDK, and the recommended version is Oracle's Java (JDK or SE 7 and above). So, you can either delete the OpenJDK 7 JRE and install Oracle's Java JDK 8 in it's place, or install Oracle's Java JDK 8 and keep the OpenJDK 7 JRE. Either way you have to tell Linux Mint which Java is the default by using the 'update-alternatives' command. This 'how-to' implements the second option - install Oracle's Java JDK 8 and keep the OpenJDK 7 JRE.

Point your web browser to the Oracle SE download page here and download the latest version of the  32-bit or 64-bit JDK (not Server JRE or the JRE) - currently at version 8u31 (or 1.8.0_31). It is also recommended that you download the API docs and demos (+samples) for the JDK - although this is not required for Android development on Android Studio. Once the packages have been downloaded, execute the following commands:

  cd Downloads
  tar xzvf jdk-8u31-linux-x64.tar.gz
  tar xzvf jdk-8u31-linux-x64-demos.tar.gz
  unzip jdk-8u31-docs-all.zip -d jdk1.8.0_31


The last 2 commands in the above is only applicable if you have downloaded the demos and the documentation. The 2nd command above will create a 'jdk1.8.0_31' directory in the Downloads directory while the last 2 commands above (if applicable) will create the 'sample', 'demo' and 'docs' directories under the 'jdk1.8.0_31' directory.

Now execute the following commands:

  sudo mv jdk1.8.0_31/ /usr/lib/jvm/
  cd ~


This will move the whole jdk1.8.0_31 directory to the /usr/lib/jvm directory - where the root of the current OpenJDK 7 JRE resides. If you are curious (like me), you can do a 'ls -la /usr/lib/jvm' command to find out what resides in this directory. Don't be surprised to find both the OpenJDK 6 and OpenJDK 7 directories listed there - why I don't know. Notice also that there is also a 'default-java' link which currently points to java-1.7.0-openjdk-amd64. This link is actually set by the 'default-jre' and the 'default-jre-headless' package which are installed by default. To remove this link, execute the following command in a terminal:

  sudo apt-get remove default-jre default-jre-headless

Notice that the owner and group of the jdk1.8.0_31 directory is still in your name and group. You can keep it as it is if you are the only user of the PC or you can set this to root by executing:

  sudo chown -R root:root /usr/lib/jvm/jdk1.8.0_31

The next thing to do is to tell Linux Mint where Oracle Java JDK resides. For this we use the 'update-alternatives' command. Execute the following commands one by one from the terminal (note that all commands are on a single line):

  sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_31/bin/java" 1500 --slave "/usr/share/man/man1/java.1" "java.1" "/usr/lib/jvm/jdk1.8.0_31/man/man1/java.1"
  sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_31/bin/javac" 1500 --slave "/usr/share/man/man1/javac.1" "javac.1" "/usr/lib/jvm/jdk1.8.0_31/man/man1/javac.1"


These will install all the necessary links to Oracle's Java. Note that the 2nd command is strictly not essential to Android program development - it only sets up the link for the Java compiler.

Next we have to tell Linux Mint the default Java to use. Just remember that Open JDK 7 Java is the default Java for a newly installed Linux Mint 17 system - however, since we installed the above links with a priority of 1500 (higher than OpenJDK's 1075), the default Java was automatically set to Oracle's Java.

To verify that all have been set correctly, you can use the following commands:

  update-alternatives --display java
  update-alternatives --display javac


If the output to the two queries above contains the following lines:

  link currently points to /usr/lib/jvm/jdk1.8.0_31/bin/java
  link currently points to /usr/lib/jvm/jdk1.8.0_31/bin/javac


then everything have been set correctly. Just another quick check can be performed by executing the following command:

  java -version

If the output for the command is:

  java version "1.8.0_31"
  Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
  Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


then Oracle JDK 8 has been set up properly.

Now that Linux Mint has been informed about Oracle's Java, you still have to perform one last task before Java is set up and ready for use. This is to set the environment variables and paths correctly for the whole system. Execute the following command:

  sudo nano /etc/profile

This will execute the nano text editor and open the /etc/profile file for editing. Now add the following lines at the end of the file.

  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_31
  export PATH=$PATH:$JAVA_HOME/bin


Save the file and close it. Note that, upon system startup, these will set the JAVA_HOME and PATH environment variables for the whole system. The JAVA_HOME environment variable points to the JDK root while the PATH environment variable will add the /bin directory of the JDK to whatever path that has already been specified. This will enable the 'javac' command to be executed from any directory.

Now log out and then log in again to the Linux Mint system in order to make sure that both the environment variables are set. Check by opening a terminal and executing one by one:

  echo $JAVA_HOME
  echo $PATH


You can then delete the tar.gz and zip files which were downloaded from the web in order to free up disk space.

Now that you have installed Oracle JDK 8 on your system, it's time to download and install Google's Android Studio. Point your browser to here and click on the big green button and then on android-studio for Linux package (NOT the SDK tools only). Wait for the download to finish and then start a terminal and execute the following command:

  unzip Downloads/android-studio-ide-135.1641136-linux.zip

This will decompress the contents of the zip file downloaded into a new directory called 'android-studio'. To start Android Studio setup, execute the following commands, one by one:

  cd android-studio/bin
  ./studio.sh


A window similar to the one shown below will appear asking whether you would like to import any settings. If this is the first time you are using Android Studio, it will be likely that you don't have anything to import. However, if you are moving from an older version of Android Studio, you may want to keep any settings made previously - in this case specify the location of the settings and let the setup wizard do the job.


Click on the OK button to proceed. Android Studio will begin loading as shown in the figure below.


After a while, the Setup Wizard screen similar to the one shown below, will appear. Click on the Next button to continue.


The next screen similar to the one shown below will appear.


The Standard type of setup is already selected - this is recommended unless you want to customize the setup. Click on the Next button and the the next screen will appear.


If you are using Linux Mint 17.1 and you have Virtualization Technology (vt-d) enabled in your PC BIOS and Linux kernel, then it will be detected as shown on the wizard's screen. You can read up more on this technology at the URL shown on the screen - just remember that the web page there is for Windows only - to read more on Linux and Virtualization Technology, click here. Then click on the Next button.

The next screen that appears as shown below is where you agree to accept the license for installing Google's Android SDK. Note that this is a must and cannot be skipped if you want to develop software for the Android platform. Click on Accept and the the Finish button.


The SDK components will begin downloading as shown in the screen below.



Once downloading and installation is completed, a log window will appear as shown. Click on the Finish button.



The next screen shown is the Android Studio IDE itself (shown below). You have now successfully installed Android Studio on your Linux Mint 17.1 PC.



Notice the 'Check for updates now.' on the IDE window - click on Check and if there are any updates, a window similar to the one shown below will pop up.



Click on the Update and Restart button. Android Studio will close and the updates will begin downloading as shown.



Once the updates have been installed, Android Studio will start again.

Congratulations! You have successfully installed Oracle's Java and Google's Android Studio on your Linux Mint 17.1 PC. Remember that, at the moment, you have to start a terminal, change to the correct bin directory and then launch studio.sh in order to start Android Studio. Surely there must be an easier way and there is! To place a launcher icon on your desktop, follow the steps outlined below:
  1. Right-click on an empty portion of your desktop and select 'Create a new launcher here...'
  2. A window similar to the one shown below, will appear. You an now enter a name for the item - 'Android Studio' seems appropriate here. Then for the command, click on the Browse button and select the 'studio.sh' file in your home directory. In the comment field, enter any text you like - 'Google's Programming IDE for Android' seems appropriate here. Leave the 'Launch in Terminal?' field unchecked.
  3. For the icon, click on the rocket icon, and navigate to your home directory, double-click on android-studio and bin directories and then select the idea.png file. Then click OK, followed by another OK.



A window may pop up asking you whether you want to create a menu item for Android Studio also. Should you say 'Yes', that item will be placed in the 'Other' category but will not be visible until you log off and log in again. You can test the launcher by double-clicking on it.




Where to go from here? You must realize that Android Studio is relatively new (Google was using Eclipse IDE previously) so the number of good tutorials on the web is limited. However, a quick search on Google revealed some good sites - I recommend that you visit some of the sites and see whether they meet your needs.

Happy computing!



EDIT: This blog was edited to use the latest Java from Oracle - Java SE update 31. In addition, the 'update-alternatives' command were changed to use 1500 as the 'priority' option, in order to set the system to use Oracle's Java automatically. Because of this change, the 'update-alternatives --set' commands were removed. Also, it was found that it was unnecessary to remove the links to the OpenJDK 7 Java - the 'update-alternatives' command will take care of which Java to use by default.

Some of the 'update-alternatives --list' commands were replaced by the 'update-alternatives --display' commands as these were more appropriate in these situations.

Strictly speaking, it is not necessary to set the PATH environment variable to include the Java bin directory in order to execute the 'javac' command, but I leave this to user to decide. No harm will come to the system if you do this. The rest of the blog remains unchanged.

Take note that there are more Oracle Java commands that can be set by using 'update-alternatives', but the minimum required by Android Studio is given in this blog. For those who wants to set up a Oracle Java programming environment, read my blog here.



Sunday, December 28, 2014

How To Remove OpenJDK 7 From Ubuntu 14.04

After reading my previous article on installing Oracle Java on Ubuntu 14.04, one of my college asked me how to remove OpenJDK 7 from his Ubuntu system. After helping him out, I realize that the process may be useful to people in the same situation. For example, if you do get a warning from Android Studio similar to the one shown below, then it's time to remove OpenJDK 7 and install Oracle's JDK 8 in its place. For instruction on how to install Oracle's JDK 8, see my blog here.



First, check for all Java installed (just in case) by executing the following command in a terminal.



sudo update-alternatives --config java


If you see a response such as the one shown below, then there is only one Java installed.


There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Nothing to configure.



As a safety check, execute the following also:


sudo update-alternatives --config javac


Again, if you see something similar to the one shown below, then there is also one java compiler installed.


There is only one alternative in link group javac (providing /usr/bin/javac): /usr/lib/jvm/java-7-openjdk-amd64/bin/javac
Nothing to configure.



To list out all the Java packages already installed, execute the following command:


sudo dpkg --list | grep -i jdk


The listing will show all the OpenJDK packages that you need to remove. To list our all the JRE packages, execute the following command:


sudo dpkg --list | grep -i jre


To actually remove all the installed OpenJDK packages, you can either use a terminal and execute the proper commands, or, if you have Synaptic installed on your system, use it to remove the installed packages. Of these 2 methods, using Synaptic will be described first.


Launch Synaptic and then type 'openjdk' in the Quick filter text box. A screen similar to the one below (the screen has been expanded for clarity) will appear. Click on each of the green box to the left of each item you want removed and select 'Mark for Complete Removal'. Should you get an additional window pop-up asking you to mark additional packages, click on the 'Mark' button.  When everything is done, click on the 'Apply' button. Another window will pop up - click on the 'Apply' button and the removal process will begin. Close Synaptic when done.


To remove OpenJDK using the command line in a terminal, open a terminal and execute:


sudo apt-get purge openjdk*

Enter your password if prompted, and then press the Enter key to accept the the default of 'Yes'. The OpenJDK packages will all be purged from the system. You can dos a quick check by using the commands:

sudo dpkg --list | grep -i jdk
sudo dpkg --list | grep -i jre

These 2 commands will return nothing, indicating that all OpenJDK related packages has been removed.

That's it - to download and install Oracle JDK 8, follow the instructions in my previous blog.

Installing Android Studio on Ubuntu 14.04 LTS

This article will guide you on how to install Google's Android Studio and set it up properly. For those of of you wondering what is the Android Studio, it is simply the IDE (Integrated Development Environment) for the Android platform. Basically it contains all the necessary tools for developing Android software, for example, an IDE and the Android SDK tools, etc. It replaces the Eclipse-based ADT formerly used by Google.


IMPORTANT NOTE FOR 64-BIT USERS: If you are using the 64-bit version of Ubuntu 14.04 LTS, it is important to note that Android Studio requires the 32-bit libraries to run properly. Although this requirement is not clearly stated under 'System Requirements', the clue is obtained from the message 'Tested on Ubuntu® 12.04, Precise Pangolin (64-bit distribution capable of running 32-bit applications'. The standard installation of 64-bit Ubuntu 14.04 LTS DOES NOT have the capability of running 32-bit applications, instead you must manually install the necessary packages by executing the following:

  sudo dpkg --add-architecture i386
  sudo apt-get update
  sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386


First you need to download Android Studio. Point your web browser to here - click on the 'Download Android Studio' button. On the next page that appears, and under the 'All Android Studio Packages' section, click on the file for the Linux platform.The terms and conditions page will appear - if you have agreed with it, select the the radio button that says so, then click on the blue button to start the download. Save the zip file and wait for the download to finish.

Start a terminal and from your home directory, execute the following command:

  unzip Downloads/android-studio-ide-135.1641136-linux.zip

This will decompress the contents of the zip file downloaded from your Downloads directory into a new directory called 'android-studio'. To start Android Studio setup, execute the following commands, one by one:

  cd android-studio/bin
  ./studio.sh

A window similar to the one shown below will appear asking whether you would like to import any settings. If this is the first time you are using Android Studio, it will be likely that you don't have anything to import. However, if you are moving from an older version of Android Studio, you may want to keep any settings made previously - in this case specify the location of the settings and let the setup wizard do the job.



Click on the OK button to proceed. Android Studio will begin loading as shown in the figure below.


After a while, the Setup Wizard screen similar to the one shown below, will appear. Click on the Next button to continue.



The wizard will start off by trying to detect where Java is installed - if you have installed and set up Oracle's Java in /usr/lib/jvm, then the wizard will find it and the next screen shown will appear.



The Standard type of setup is already selected - this is recommended unless you want to customize the setup. Click on the Next button and the the next screen will appear.



If you are using Ubuntu 14.04 and you have Virtualization Technology (vt-d) enabled in your PC BIOS and Linux kernel, then it will be detected as shown on the wizard's screen. You can read up more on this technology at the URL shown on the screen - just remember that the web page there is for Windows only - to read more on Linux and Virtualization Technology, click here. Then click on the Next button.

The next screen that appears as shown below is where you agree to accept the license for installing Google's Android SDK. Note that this is a must and cannot be skipped if you want to develop software for the Android platform. Click on Accept and the the Finish button.


The SDK components will begin downloading as shown in the next screen.

    
Once downloading and installation is completed, a log window will appear as shown. Note that, if you are using a 64-bit Ubuntu 14.04 LTS and did not install the required 32-bit packages, an error message about being unable to create an Android virtual device will appear on the last line. Click on the Finish button.


The next screen shown is the Android Studio IDE itself (shown below). You have now successfully installed Android Studio on your Ubuntu 14.04 PC.


Notice the 'Check for updates now.' on the IDE window - click on Check and if there are any updates, a window similar to the one shown below will pop up.


Click on the Update and Restart button. Android Studio will close and the updates will begin downloading as shown.

  
Do not close the Android Studio IDE window yet. There is one more thing to do before you can start to use Android Studio. Remember that, at the moment, you have to start a terminal, change to the correct bin directory and then launch studio.sh in order to start Android Studio. Surely there must be an easier way and there is! But, in order to setup the easier way, there are several things that must be done.

The first is to create a launcher item in the Unity launcher. This is easily accomplished by right-clicking on the Android Studio icon in the launcher and click on the 'Lock to Launcher' item. The Android Studio launcher (as shown by the green arrow in the screenshot below) will then remain permanently in the launcher until you remove it - but remember that the Desktop Entry for the launcher will still need to be edited before it can work properly.

 
The second is to edit the Desktop Entry text file for the
Android Studio launcher. Launch a terminal and execute the following:

  nano .local/share/applications/jetbrains-android-studio.desktop

Remember that this command is all on one line and don't forget the dot (or period) before local - this is NOT a typo as .local is a hidden file. The contents of that file need to be edited as follows:

a)  Remove the 'Setup' from the 'Name' item.
b)  Edit the 'Exec' item to /home//android-studio/bin/studio.sh (replace with your login name - in case you forgot, this is the same login name as the 'Path' item in the previous line). Note that the unedited line is for the setup command and is rather long - make sure that you remove it completely before entering the new command.
c)  Insert a line after the 'Exec' line, and type 'Terminal=false'.

Leave the rest of the items unchanged. The final file will look something like this:


Save the file and exit nano. To test whether the launcher works, first close Android Studio and then click on the launcher - Android Studio should re-open. If not, check your Desktop Entry file again.

If you want to launch Android Studio from anywhere using 'studio.sh', it is recommended that the system wide path include the android-studio/bin. To do this, execute this command in a terminal:

  sudo nano /etc/profile

In the 'profile' file make sure to include the android-studio/bin in the PATH - for example:

  export PATH=$PATH:$HOME/android-studio/bin

Save the file and close nano. To make sure that this new path takes effect, log out and then log in again. Now you can launch 'studio.sh' in a terminal from any directory. 

That's it - you are now ready to use Android Studio for developing software on the Android platform.
    

Friday, December 26, 2014

Installing Oracle Java JDK8 On Ubuntu 14.04

So you have installed a brand-new Ubuntu 14.04 LTS OS on your PC and tweaked it just the way you like it. Now you want to do a bit of Java programming on it and wonder how to go about doing it. Let this article be the guide to show you how to install Oracle's JDK 8 Java and set it up properly.

First you should be aware that there is no Java installed on a freshly intalled Ubuntu 14.04 LTS. This can be verified easily by executing 'java -version' in a terminal. This article assumes that there is no Java installed.

Why Oracle Java? Why not OpenJDK? Good question and the answer is that it is recommended by Google. Should you plan to use Java for Android programming later, then Google says it is better to use Oracle's version - their Android Studio says that there are stability issues with OpenJDK. Whether this is true is a moot point here - if you do plan to do Android programming later, then install Oracle's Java - else, any Java will do, even OpenJDK.

Here are the steps for installing Oracle JDK 8. Note that a web browser is used to download the JDK - not Ubuntu Software Center or Synaptic.

  1. Point your browser to here and click on the JDK download button (not the Server JRE or JRE). On the page that appears next, click to 'Accept License Agreement' and select either the 32-bit or 64-bit tar.gz file to start the download. Save the file and wait for the download to finish. If you have not changed anything, the JDK file will be found in your Home folder Downloads location.
  2. On the same web page, scroll down and click on either the 32-bit or 64-bit Demo and Sample file for downloading. Again, save the file and wait for the download to finish,
  3. Use the 'Back' key for your browser to go back one page and scroll down until you see Java SE 8 Documentation and click on the download button. On the next page, accept the license agreement and click on download the zip file for the documentation for the JDK (not the JavaFX). Save the file and wait for the download to finish.
Now that you have downloaded the files, it's time to install it. First open a terminal and change directory to the Downloads folder (or to the folder in which you saved the downloaded JDK files) by executing:

  cd Downloads

Then extract the contents of the 'jdk-8u25-linux-x64.tar.gz' file by executing:

  tar xzvf jdk-8u25-linux-x64.tar.gz

This will create a  'jdk1.8.0_25' directory in the Downloads directory while displaying a lot of stuff on the terminal's screen. After this is completed and you are back to the command prompt, you can extract the demos and samples by executing:

  tar xzvf jdk-8u25-linux-x64-demos.tar.gz

This will create 2 directories under the 'jdk1.8.0_25' directory - 'sample' and 'demo' directories. When completed, you can now extract the Java API documents by executing:

  unzip jdk-8u25-docs-all.zip -d jdk1.8.0_25

This will create a 'doc' directory under the 'jdk1.8.0_25' directory. After this is completed, you now have all the files necessary for the Oracle Java JDK 8 - all you have to do is to put them in the proper place.

The 'proper place' can be anywhere - your home directory (if you want Java for your own use only) or '/usr/local/' or 'usr/lib/jvm', etc. Note that if you want Java to reside as a sub-directory in '/usr/local/' or '/usr/lib/jvm/', then you need to use 'sudo' since administrator privileges are needed to create sub-directories there. This is not required if you install Java in your home directory. For this article, we will use '/usr/lib/jvm/' directory as this is where all Java related files end up if it was installed by default.

First we have to create the /usr/lib/jvm directory by executing:

  sudo mkdir /usr/lib/jvm

Next, we move the 'jdk1.8.0_25' directory to /usr/lib/jvm

  sudo mv ~/Downloads/jdk1.8.0_25/ /usr/lib/jvm/

The directory will be moved from your home Downloads directory to the '/usr/lib/jvm/' directory. You can verify this by listing the contents of the 'usr/lib/jvm/' directory using the 'ls -la' command. Note that the owner and group for the jdk1.8.0_25 directory is yours but you can easily change this by executing:

  sudo chown -R root:root /usr/lib/jvm/jdk1.8.0_25

Again, you can verify this by using the 'ls -la' command.

The next thing to do is to tell Ubuntu where Oracle Java JDK resides. For this we use the 'update-alternatives' command. Execute the following commands one by one from the terminal (note that all commands are on a single line):

  sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_25/bin/java" 0

  sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_25/bin/javac" 0

These will install all the necessary links to Oracle's Java. Next we have to tell Ubuntu the default Java to use. Execute the following commands one by one from the terminal (note that all commands are on a single line):

  sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_25/bin/java

  sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_25/bin/javac

To verify that all have been set correctly, you can use the following commands:

  update-alternatives --list java

  update-alternatives --list javac

If the output to the 2 queries above are /usr/lib/jvm/jdk1.8.0_25/bin/java and  /usr/lib/jvm/jdk1.8.0_25/bin/javac, then everything have been set correctly. Now that you have informed Ubuntu about Oracle's Java, you still have to perform one last task before Java is set up and ready for use. This is to set the environment variables and paths correctly for the whole system. Execute the following command:

  sudo nano /etc/profile

This will execute the nano text editor and open the /etc/profile file for editing. Now add the following lines at the end of the file.

  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_25
  export PATH=$PATH:$JAVA_HOME/bin

Save the file and close it. Note that, upon system startup, these will set the JAVA_HOME and PATH environment variables for the whole system. The JAVA_HOME environment variable points to the JDK root while the PATH environment variable will add the /bin directory of the JDK to whatever path that has already been specified. This will enable the 'javac' command to be executed from any directory.

Now log out and then log in again to the Ubuntu system in order to make sure that both the environment variables is set. Check by opening a terminal and executing:

  echo $JAVA_HOME

  echo $PATH

Then as the last check, execute the following:

  java -version

  javac -version

If you see 'java version "1.8.0_25"' and 'javac 1.8.0_25' in the output, then you are now ready to use Oracle's Java on your Ubuntu system. You can also delete the tar.gz and zip files which were downloaded from the web in order to free up disk space.

Where to go from here? If you are familiar with Java programming, you can go ahead to use Java anyway you like it. If you are a novice and this is the first time you are using Java, then I would recommend searching the web for tutorials and the books "Java For Dummies, 6th Edition" and "Head First Java, 2nd Edition" as a guide. Happy Computing!

Sunday, October 12, 2014

Ubuntu 14.04.1 Post-Install Setup

Introduction

This article serves as a guide for the user of a just-installed Ubuntu 14.04.1 PC or notebook to set up the system properly. It is applicable to both the 32-bit and 64-bit system.

After the installation of Ubuntu has been completed and the system boots up for the first time, the user will be presented with the login screen. Log into the system using the user name and password specified during the install process and, if successful, the user will be presented with the Unity desktop as shown below. Click on any item on the launcher to dismiss the keyboard shortcut pop-up window.


Now it's time to carry out the post-install setup of the system. The setting up will vary according to individual tastes - you do not have to follow all the steps outlined in this article. Simply view this article as a guide to setting up the system after installation. Keep this in mind - there is no "perfect desktop" for everyone - each desktop may differ according to the taste of the individual using the system. There are, however, some things that need to be carried out by everyone after installation - for example, updating the software on the system - the first task listed below.

Updating The System

If the user is connected to the Internet and if there are any updates available, a notification will appear after a while in the launcher as shown in the figure below (as indicated by an arrow in the figure).


If cursor is moved onto the item on the launcher, the tooltip will read "Software Updater".


Click on the software updater launcher and the following window will pop up.


Then click on the "Install Now" button and the updating process will start and the user will then be prompted to enter the password for authentication.



Enter the password and then click on the "Authenticate" button. The update process will start downloading all the updates from the server (as shown in the figure below) and then install them. Wait for the update to complete.


Once completed, the software updater will automatically display a notice that the system is up to date if a system restart is not required. If a restart is required, the window shown below will appear - click on the "Restart Now..." button to restart the system. Log in again and the user will be at the Unity desktop once more.



Disabling The Amazon Search

Canonical has done a lot to improve the Ubuntu desktop. However, the author feels that there are 3 major 'improvement' that will not be missed if they were removed or addressed. One of the 'improvement' is that Canonical has integrated Amazon (the American based international online commerce company) search result into the Unity dash - the overlay that allows the user to search quickly for information both locally (applications, files, bookmarks, etc.) and remotely and displays previews of results. The dash is opened by clicking on the first (topmost) item in the launcher and then the item to search for is typed into the search box.


Whenever you search for an application or file on your computer in the dash, your search is sent to Canonical's servers. They forward your request to Amazon and displays you the Amazon search results. If you click an Amazon link in order to buy anything, Canonical gets a commission.

A majority of Ubuntu users (including the author) does not like this feature and almost the first thing they do is to disable it. The easiest way is to use the "System Settings" window by clicking the gear icon in the launcher. The system settings will open as shown.


Click the "Security & Privacy" icon, then click the "Search" tab, and toggle the "Include online search results" option to "Off" (see figures below).




Note that using this procedure will also disable all other online search results in the dash. To remove the "Amazon" icon from the launcher, just right-click on it and select "Unlock from Launcher" and it is gone - RIP Amazon Search.


Tuning The System

While the "System Settings" window is open, now would be a good time to set up the system to your liking. The user should still be in the "Security & Privacy" part of the system settings (if the user have not exited system settings). Click on the "All Settings" tab to go back to the system settings main window.

From this window, it is possible to change the way the desktop looks, set up the various pieces of hardware to work with the system, set up backup for the system, etc. There are 3 main categories - Personal, Hardware and System - the user can explore each possible setting by clicking on the icon for the item. For example, click on "Details" to see details like default applications, etc (see figure below).


Using the author's desktop as an example, the following tasks were carried out:
  1. Using "Appearance", the wallpaper was changed from the standard purple coloured wallpaper to 'Beach' - a more pleasing (to the author) wallpaper



    Click on the "Behaviour" tab and a window similar to the one shown below will appear. From here the user can change another 'annoying' feature of Ubuntu (2 of 3) - click "In the window's title bar" under "Show the menus for a window" item. Menus for the focused window won't appear on the top bar (the default behaviour) if this is enabled. Instead, they’ll appear in the window’s title bar. This will make Ubuntu seem more familiar if the user are used to Windows and traditional Linux desktops. Be aware that this menu will only appear when the user hover the mouse over the title bar. This menu will be hidden most of the time.


  2. Using "Sound", the sound hardware for the system was set up. Items like volume, input, etc was set and tested.


    On the author's system, the output was set to the 'Analog Output', the built-in audio device (see figure above). The 'Input' was set to the Webcam C250 (a Logitec device) as shown in the figure below.


    The 'Sound Effects' and 'Applications' was set at their default values. Also set as shown was the 'Output volume' level. Note that the output setting can be tested by clicking on the 'Test Sound' button.

  3. Using "Language Support", the language selected was corretly set up. The screen shots may differ from those shown below if the user selected a different language during install.





  4. Using "Bluetooth", any Bluetooth devices can be 'paired' with an Ubuntu PC or notebook which have Bluetooth devices and services enabled. However, be aware that not all Bluetooth PC 'dongle' will work with Ubuntu. The author had several 'dongle' in his possession, ranging from old ones (which looks like a USB thumb drive) to the latest and very tiny 'dongle'. After testing all the 'dongles', the author found out that only a few worked - and those were the newer models. So, if your 'dongle' does not work with Ubuntu, try another one.

    Before attempting to pair a Bluetooth device with Ubuntu PC, plug in the 'dongle' (notebooks usually comes with Bluetooth, so ignore this if you are using Ubuntu on a notebook). Then check the 'notification' area on the top right corner of the screen - you should see the Bluetooth icon there if your 'dongle' works with Ubuntu (see figure below).


    If the Bluetooth icon is clicked, you should see that Bluetooth services is enabled by default (see figure below).


    The user can now proceed to pair a Bluetooth device with Ubuntu. As an example, the author has a Samsung Galaxy Note 2 Android smartphone (model number GT-N7100 running Android version 4.4.2) which will be used as the Bluetooth device to pair with Ubuntu. Of course, the phone will need to have it's Bluetooth sevices enabled and this is easily done with the following steps:

    1. Touch "Settings"
    2. Then enable Bluetooth by touching the 'switch' to 'On'
    3. Then touch the 'Bluetooth' item and in the 'My device' screen, make sure that the GT-N7100 device is visible by enabling it - just touch the checkbox. While the smartphone is visible (a timeout timer will start on the smartphone), the following steps need to be performed on the Ubuntu PC or notebook.
    4. Click on the Bluetooth icon on the Ubuntu PC
    5. Select "Set Up New Device..."
    6. The 'Bluetooth New Device Setup' screen (shown below) will appear with the words 'Searching for devices...' on it. After a while (and if the visibilty of the smartphone has not timed out), the item "GT-N7100" will be listed as shown. Select the device by clicking on it and then the "Continue" button.


    7. The next screen (shown below) will prompt you to enter the indicated PIN number on the smartphone. At this time you will hear a 'beep' from the phone and you will be prompted on the phone to enter the PIN number indicated on the PC (or notebook) screen.


    8. Enter the PIN number on the smartphone, touch "OK" and the screen on Ubuntu will change to the one shown below - indicating success with the pairing (the PC or notebook name will also appear on the smartphone as one of the paired devices).


    The user can now easily exchange files between the phone and Ubuntu.

    By following the steps outlined above, the user can easily set up any Bluetooth enabled devices on Ubuntu.

    Just be aware that leaving the Bluetooth services enabled on the smartphone will drain the phone's battery faster - so remember to switch off Bluetooth after using it.

    To remove (or unpair) a Bluetooth device (the smartphone in this case) follow the steps below:

    1. On the smartphone, touch "Settings" and enable Bluetooth (if it is off), then touch the "Bluetooth" item
    2. On the screen that appears next, touch the gear icon to the right of the PC (or notebook) name, then touch "Unpair" (the PC or notebook name will be listed under "Available devices"). Exit from here
    3. On the PC (or notebook), click on the Bluetooth icon on the notification bar ans select "Bluetooth Settings..."
    4. On the screen that appears next, select the device by clicking on it (see figure below) followed by a click on the "-" (minus) button below. You will be prompted to confirm the removal (see figure below) - click "Remove" to remove the device



    5. The smartphone will be removed (unpaired) - close the settings window

    Any Bluetooth device can be easily removed by following the steps above - consult the device manuals if unsure of the unpairing procedure. Just remember that once a Bluetooth device is removed or unpaired, it need to be re-installed before it can be used again. Also remember that only paired devices are 'visible' to each other so there is no need to enable visibility on the devices.

  5. Using "Printers", the user can easily add printers to Ubuntu. Before using the "Printers" setting, make sure that the printer is connected to the Ubuntu PC or laptop and is powered up. Then click on the "Printers" item and you will see a screen similar to the one below.


    Click on "Add" and the screen as shown below will appear - if the printer is recognized, it will be listed as shown (an HP LaserJet Professional P1102 in this example). Click on that item and then on the "Forward" button.


    It will then start a search online for the correct driver for the printer and if found, the screen will change to the one similar to the one shown below. Click the "Apply" button and the printer will be installed.


    The next screen will prompt you to print a test page - do so and a "Submitted" window will appear (see below).



    Click "OK" and the "Printer Properties" window will appear (see below). You can now change any setting if desired - then click "OK".


    You will now be back at the "Printers" window (see below) but with the just installed printer listed.


    Note the green-colored checkmark - this denotes that the printer is the default printer so all print jobs will be routed to this printer. If you have more than one printer installed, the setting up of a default printer can be easily set up by using the printer properties.

Setting Up The Terminal

A terminal or console is useful for times when the user is required to execute commands on a line instead of using a GUI. Before using a terminal, however, it would be advisable to configure it to the user's taste. The author prefers the terminal to be of larger size and use a larger font. As mentioned previously, it will be up to the user to configure the terminal as desired - the procedure is the same.

First click on the dash and then type 'terminal' as shown into the search box. Then click on the 'Terminal' icon under 'Applications' - ignore 'UXTerm' and 'XTerm'.


A terminal will open up. Move the cursor to the title bar of the terminal window and the menu items for the terminal will appear as shown below.


Click on 'Edit' and 'Profiles' to open the profile window as shown below.


The 'Default' profile is already selected so click the 'Edit' button. You can now edit any items for the default profile (shown below) to suit your taste.


The author has chosen the Monospace 12pt font by removing the tick mark from the 'Use the system fixed width font'. The author also has increased the size of the terminal window to 110 columns and 34 rows. The final settings used by the author is as shown below.


Click 'Close' to close the settings window followed by another click on the 'Close' on the profile window. Notice that the changes made will not be reflected on the currently open terminal window. You need to close the terminal window and re-open it to see the changes but before we do it, we need to lock the terminal icon on the launcher to make it easier to launch a terminal. To do this, right-click on the terminal icon in the launcher, and the click on the 'Lock to Launcher' item. Then close the currently open terminal window. Click on the terminal icon on the launcher and the re-sized terminal window will open.


Installing Software From The Command Line

While the terminal is open, the following software will be installed using the 'apt-get' command on the command line. Type the following command as shown below:

  sudo apt-get install mc synaptic

You will be prompted to enter your password - do so and the command will execute and the screen will change to one similar to that shown below. Press the 'Enter' key to accept the default 'Y'. The various packages will downloaded and then installed.


The two packages installed are mc - a terminal based file management system and synaptic - an old-style software package management system. Note that a newer software package management system called 'Ubuntu Software Center' is installed by default and an icon is present for this in the launcher. The reason why the author chose to install this package is simply because he is more comfortable using this old-style software package management system.

If you recall from the figure shown above, there were old kernel files that can be removed from the system to free up disk space using the 'apt-get autoremove' command. Do so by typing in the following:

  sudo apt-get autoremove

The old kernel files will then be removed from the system. One last task before the terminal is closed and that is to bring back the old-style scroll bar back. If you notice, the new 'scrollbar' (in the form of a button), is normally hidden until you move the mouse pointer over the left side of a window. If the user is unconfortable with this (like the author), the old style scrollbar can be restored by executing the following command in the terminal.

  gsettings set com.canonical.desktop.interface scrollbar-mode normal

Note that the whole command should be on one line. After this command is executed, the familiar old style scrollbar should appear to the left of any window of appropriate size.

The terminal window can now be closed.


Installing Software From Ubuntu Software Center

As a last post-install task - that of installing the Dropbox software using Ubuntu's new Software Center. Note that the same task can be accomplished via the command line or the old style Synaptic Package Manager - the use of Ubuntu's Software Center is the new way to go. Follow the steps below for the installation:
  1. Click on the Ubuntu Software Center icon on the launcher

  2. Type 'dropbox' into the search box

  3. Click on the first item (Dropbox) in the list followed by a click  on the 'Install' button

  4. Enter your password to authenticate

  5. Wait for the Software Center to finished downloading and installing Dropbox (a rotating arrow will be shown along with a number 1 on the 'Progress' item in the top bar)

  6. To indicate the completed job, the 'Install' button will change to 'Remove'

  7. Close the Software Center and an 'Information available' window will be shown - since the Nautilus file manager is not open, this message can be ignored

  8. Click the 'Next' botton and the message will change to "Start Dropbox to finish installation' - click on the 'Close' button

  9. Click on the Dropbox icon in the launcher

  10. After a while, the Dropbox Setup window will appear. If you don't have a Dropbox account, click 'Next' and follow the on-screen instructions. If you already have an account (like the author), select 'I already have a Dropbox account' and click the 'Next' button

  11. Enter the correct email address and password information and then click the 'Next' button

  12. Select the setup type - the recommended one ('Typical') should suffice for most people

  13. You can now take the tour of Dropbox or you can skip it entirely by clicking on the 'Skip Tour' button

  14. Dropbox setup is now complete - click the 'Finish' button to exit setup and open the Dropbox folder

  15. If this is the first time you are using Dropbox, you will find that there very little contents in your Dropbox folder - however, if you are like the author (as shown below) and have lots of stuff in Dropbox, it will take time for Dropbox to sync with the cloud

  16. To make access to Dropbox easier within the Nautilus file manager, create a bookmark by clicking 'Bookmarks' and selecting 'Bookmark this Location' - Dropbox will now be found under the 'Bookmarks' section of the file manager



That's it - Dropbox is now installed on your Ubuntu system and you can now use it.

This concludes the basic post-install tasks of a freshly installed Ubuntu 14.04.1 system.


Summary

As a summary, the following steps are performed after installing Ubuntu 14.04.1:
  1. Update the system - reboot if necessary
  2. Disable Amazon Search using System Settings
  3. Tune the system using System Settings and fix menu display
  4. Set up the terminal and fix scrollbar
  5. Install other software as necessary
That's it - the Ubuntu 14.04.1 system is now ready for use. Enjoy!