Linux Tips : Setting Java programming environment in Ubuntu Linux

I do a lot of programming in Ubuntu Linux. A couple months ago I started to learn JAVA, previously I have used to program in C/C++ which fortunately Ubuntu is already built in GCC (GNU C Compiler) so everything works out of the box. Unfortunately the case is not the same as JAVA, Ubuntu is not shipped with Java JDK/JRE. So, you must install everything by yourself.

I found out one of my favourite IDE in Windows that support JAVA programming is also available on Linux, it is NetBeans. Netbeans is free Integrated Development Environment (IDE) that supports a lot of languages, including Java, JavaScript, PHP, Python, Ruby, C/C++ and more. NetBeans is written in Java and runs with Java Virtual Machine (JVM) installed. For Java development functionality you must install JDK first, but for other languages you can just install JVM.

Install JDK/JRE Ubuntu Linux

Okay, let’s start with installing JDK and JRE. There are two ways Installing JDK and JRE, the easy way is from Synaptic Package Manager and the hard way is install from .bin file. Installing from Synaptic Package Manager is the best way when you have internet connection or any access to repository (DVD, server, etc). But if your computer don’t have any access to repository server, you can download .bin file from Sun Website from other computer and install it on the computer that you want.

Option 1
First lets start with the easy way, install from Synaptic. Make sure you have the Multiverse repository enabled.

System > Administration > Software Source > Select Multisource > Close

Enable Multiverse Repository Ubuntu Linux

Open your terminal and type the following command to install JDK and JRE

$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

Wait till it download and install, depend on your connection it should take several minutes.
Make sure the correct version is used by using this command

$ sudo update-java-alternatives –s java-6-sun

Option 2

For those who want to install the hard way, first download JDK and JRE from Sun. You will get .bin file.

Download JDK bin file

Open your terminal, then go to directory where the download file is, and make sure the file is executable.

cd /directory/where/you/download/file
sudo chmod +x filename

Install the file with this command

sudo ./filename

Make sure the correct version is used by using this command

$ sudo update-java-alternatives –s java-6-sun

Install Netbeans Ubuntu Linux

Option 1
Download Netbeans from here and save it to your computer. Let’s say the file is called “netbeans-6.8-ml-linux.sh”. Run your terminal and change directory to where you download the file.

download netbeans

$ cd /direcory/where/you/download/file

Make sure the file is present by using ls command. Finally execute the following command

$ sudo ./netbeans-6.8-ml-linux

After completing command, you will see installer that will install NetBeans into /opt directory. Finish!.

Option 2
Alternatively you can also install using Synaptic Package Manager, just execute the following command.

$sudo apt-get install netbeans

Finish!.

File Storage and Retrieval

Information stored in a mass storage system is conceptually grouped into large units called files. A typical file may consist of a complete text document, a photograph, a program, a music recording, or a collection of data about employees in a company. We have seen that mass storage devices dictate that these files be stored and retrieved in smaller, multiply byte units. For example, a file stored on magnetic disk must be manipulated by sectors, each of which is a fixed predetermined size. A block of data conforming to the specific characteristics of a storage device is called a physical record. Thus, a large file stored in mass storage will typically consist of many physical records.

In contrast to this division into physical records, a file often has natural divisions determined by the information represented. For example, a file containing information regarding a company’s employees would consist of multiple units, each consisting of the information about one employee. Or, a file containing a text document would consist of paragraph or pages. These naturally occurring blocks of data are called logical records.

Logical records often consist of smaller units called fields. For example, a logical record containing information about an employee would probably consist of fields such as name, address, employee identification number, etc. Sometimes each logical record within a file is uniquely indentified by means of a particular field within a record. Such as identifying fields is called a key field. The value held in a key field is called a key.

Logical record sizes rarely match the physical record size dictated by a mass storage device. In turn, one may find several logical records residing within a single physical record or perhaps a logical record split between two or more physical records. The result is that a certain amount of unscrambling is associated within a retrieving data from mass storage systems. A common solution to this problem is to set aside an area of main memory that is large enough to hold several physical records and to use this memory space as a regrouping area. That is, a blocks of data compatible with physical records can be transferred between this main memory area and the mass storage system, while the data residing in the main memory area can be referenced in terms of logical records.

An area of memory used in this manner is called a buffer. In general, a buffer is a storage area used to hold data on temporary basis, usually during the process of being transferred from one device to another. For example, modern printers contain memory circuitry of their own, a large part of which is used as a buffer for holding portions of a document that have been received by the printer but not yet printed.

Further Reading:
1. Wikipedia : Information Retrieval, File System, Database
2. Information Retrieval Wiki

Linux Tips : Automatically find Fastest Repository Server in Ubuntu

I used to have problem when updating security update on my Ubuntu 9.10 (Karmic Koala), the connection was extremely slow even when I’m connected to fast network and occasionally the download was dropped without any reason which could lead a disastrous results. So I’ve been researching and I figured it out the problem is with my poor choice of repository server. The Repository Server I’ve had been using is apparently have some problem with their connection. Problem found and this lead to another problem, how do I look for the fastest Repository Server since there’re so many out there.

The answer is to let your system scan for the fastest server available. You will need to launch Software Sources tool, which can be found in

System > Administration > Software Sources

Ubuntu Software Sources

This administrative menu will allow you to change the location of your preferred repository, and change items within the repository you want to subscribe to. You will have the most software available if all boxes are checked.

Other Sources Ubuntu Repository

From ‘Ubuntu Software’ tab select ‘Other’ from ‘Download from:’ drop-down menu and you’ll be given a list of available server sorted with country.

To have your system test and find the faster server you can select the ‘Select Best Server’ option, which will try to connect to each repository server mirror and find the fastest response. After the process done, it will select the fastest server available and you can either change it or run the process again until you’re satisfied.

Select Best Server

note: Tested on Ubuntu 8.04 and 9.10. Your mileage may vary. Try to run the process two or three times until you find the good one. Repository mirror speeds can fluctuate based on many factors (e.g Traffic).