Tuesday, September 20, 2016

How to install Java on linux

Posted by Kishore Bhosale

Installation of Java on Linux

This article is about how to install Java on Linux. In this article we are installing Java8 on Ubuntu 16.04, In similar way you can install on any Linux distribution.


1) First check JAVA is already installed on your system or not by following command:


2) If Java is installed then it shows all option in java, else we have to install JAVA.
To install JAVA use following commands:

root@root:~$ sudo add-apt-repository ppa:webupd8team/java
root@root:~$ sudo apt-get update
root@root:~$ sudo apt-get install oracle-java8-installer

3) Before setting the environment variable we have to identify the path where the java is installed:

root@root:~$ which javac
root@root:~$ ls -l /usr/bin/javac
/usr/bin/javac -> /etc/alternatives/javac
root@root:~$ ls -l /etc/alternatives/javac

Path may be different for different Linux version, for ubuntu it's: /usr/lib/jvm/java-8-oracle/bin/javac

4) Set the environment variable in .bashrc file:

root@root:~$ gedit ~/.bashrc
Copy paste the following lines to your .bashrc file and save it.
Change java path according to your java path.
For changes in .bashrc file you require root privileges.
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/bin/javac
export PATH=$PATH:$JAVA_HOME/bin

root@root:~$ source ~/.bashrc

5) Now check java is installed or not by javac
Now, you can also check JAVA_HOME path On terminal type echo $JAVA_HOME
Great Java is properly installed on your system.
Read More

Sunday, September 11, 2016

Apache Karaf

Posted by Kishore Bhosale


Apache Karaf is a lighweigh, powerful container that supports the "run anywhere". It can be used (on any machine with Java, cloud, docker images) using the embedded mode.With this flexibility, Karaf is the perfect solution for microservices, systems integration, big data, and much more. Apache Karaf is powered by OSGi (but you don’t need to know what OSGi is to use Karaf). Apache Karaf uses either the Apache Felix or Eclipse Equinox OSGi frameworks, providing additional features on top of the framework. Apache Karaf can be scaled from a very lightweight container to a fully featured enterprise service: it’s a very flexible and extensible container, covering all the major needs.


OS: Run on any OS (Windows, Linux etc.)
Disk space:At least 20 MB but recommended 100 to 1000MB for logging, bundle cache, and repository.
Memory: At least 128 MB but 2GB recommended.
JRE: 1.6 and above.

Installation Of Karaf:

Installation of Karaf is very simple.
1) If you dont have java Install JAVA SE 7 or above version.
2) Download Karaf Click Here
3) Extract the archive to a new folder on your hard drive; for example in /home/kb/karaf
4) To start the server, run the command :/bin/karaf

Karaf Lifecycle:

Karaf is a lightweight container. In a web application, we create the war file, similarly using OSGi we create a modular application. Each module is called bundle this bundle is nothing but the jar with additional information. This module is deployed into karaf. Following is life cycle diagram for a bundle in karaf.
1) Install bundle into karaf. bundle:install "location of jar file". Bundle is in installed state.
2) Once bundle installed, all required dependency are resolved by karaf means additional jar required for that bundle is downloaded.
3) To run the bundle use start command. start "bundle ID"
4) After bundle started it is in active state.
5) To stop the bundle use command stop "bundle ID"
6) After stop the bundle it is in unresolved state. All dependency are removed.
7) To uninstall bundle use command uninstall "bundle ID"

Features provided by Karaf:

Hot deployment: simply drop a file in the /deploy/ directory, Apache Karaf will detect the type of the file and try to deploy it.
Complete Console: Apache Karaf provides a complete Unix-like console where you can completely manage the container.
Dynamic Configuration: Apache Karaf provides a set of commands focused on managing its own configuration. All configuration files are centralized in the /etc/ folder. Any change in a configuration file is noticed and reloaded.
Advanced Logging System: Apache Karaf supports all the popular logging frameworks (slf4j, log4j, etc). Whichever logging framework you use, Apache Karaf centralizes the configuration in one file.
Provisioning: Apache Karaf supports a large set of URLs where you can install your applications (Maven repository, HTTP, file, etc). It also provides the concept of "Karaf Features" which is a way to describe your application.
Management: Apache Karaf is an enterprise-ready container, providing many management indicators and operations via JMX.
Remote: Apache Karaf embeds an SSHd server allowing you to use the console remotely. The management layer is also accessible remotely.
Security: Apache Karaf provides a complete security framework (based on JAAS), and provides a RBAC (Role-Based Access Control) mechanism for console and JMX access. Instances: multiple instances of Apache Karaf can be managed directly from a main instance (root).
OSGi frameworks: Apache Karaf is not tightly coupled to one OSGi framework. By default, Apache Karaf runs with the Apache Felix Framework, but you can easily switch to Equinox (just change one property in a configuration file).

That's all for Karaf. Now you will have enough information to use KARAF for developing applications.
Read More

Monday, April 4, 2016

DSA Part 1 - Introduction

Posted by Kishore Bhosale

Hello Readers,

We will have, here, a series of articles on Data structures and Algorithm. The main objective of this series is to help readers in interview preparation, competitive exams like GATE, and campus interview preparations. It is also helpful for academic preparations. For the particular concept, we provide basic theory and then different problem-solving techniques. More importance is given to problems and analyzing them instead of concentrating more on theory.

What will be covered:

Data Structures: Abstract data type, Arrays, Structure, Pointer, Stack, Queues, Linked List, Trees, Binary search tree, Heap, Graphs, data structures for Hashing Algorithm: Algorithm complexity, Searching, Sorting, String Algorithms, Algorithm design technique: Greedy, Divide, and Conquer, Dynamic programming.


Familiarity with any high-level programming language such as C, C++, Java, Python etc.

Program: It is an implementation of an Algorithm in any programming language.

Data Structure:Way of organizing data, so we can effectively perform operations of data manipulation (update, insert, delete) and information querying (searching, sorting, traversing etc) on it and get required result or information. No single data structure works well for all purposes, and so it is important to know the strength and limitation of them.
There are basically two data types:
1) Primitive data type: Integer, float, char, boolean, double, long etc.
2) User-defined data type: Arrays, files, List. List divided into two parts Linear List(Stack, Queue) and Non-linear List(Tree, Graph)

Algorithm:It is a well-defined computational procedure that takes some input and produces output. For a particular problem, there are many algorithms. Then what is a good algorithm? The efficiency of the algorithm has majored in terms of time and space complexity. The amount of time required completing an execution of a program. Space complexity is the amount of space required by the algorithm. In upcoming articles, we learn how to measure time and space complexity of an algorithm.

References: "Introduction to Algorithms, 3rd edition, by Cormen, Leiserson, Rivest and Stein.
Read More

Saturday, March 12, 2016

Hadoop Series Part 15 - Hive Installation

Posted by Kishore Bhosale

Hive Installation:

In the previous article of Hive "Hadoop Series Part 16 - HIVE in Hadoop", we learned what is Hive, application, limitation, interface, data types, commands of Hive and so many basic concepts required to learn Hive. Hive is used for data summarization, query, and analysis. In this article, we will learn how to install and configure Hive.


Hive is running on top of Hadoop, and Hadoop is implemented in Java.


1. To download the Hive Click here.
2. Save and extract it.
3. Copy this extracted folder to /usr/local/ (You can specify your installation directory)
4. Set the environment variable HIVE_HOME in .bashrc file:

kb@kb::~$ ~/.bashrc

Copy and paste the following lines at end of the file

export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin

5. Set the HADOOP_HOME path in Hive
Open conf folder in hive
Copy hive-env.sh.template to hive-env.sh
Open hive-env.sh
Find HADOOP_HOME and paste the following line
export HADOOP_HOME=/usr/local/hadoop-2.7.0

6. Create Hive directories within HDFS:
kb@kb:~$ hadoop fs -mkdir /usr/hive/warehouse

7. Setting read/write permission for table
kb@kb:~$ hadoop fs -chmod g+w /usr/hive/warehouse

8. Start HIVE:
kb@kb:~$ hive

That's all for this article. In next article, we will study about how to write hql and UDF for a hive. Stay tuned with us to learn hive in detail. Hope this article will help you to install a hive.
Read More

Friday, March 11, 2016

Hadoop Series Part 22 - Hadoop assignment

Posted by Kishore Bhosale


Apply Hadoop MapReduce to derive some statistics from White House Visitor Log.
Download data from the site given in below. There are currently 3 million+ records available at

Data is available as web only spreadsheet view and downloadable raw format in CSV (Comma Separated Value). In CSV format each column is separated by a comma in each line. The first line represents the heading for the corresponding columns in other lines. We are going to use this raw data for our MapReduce operation.

You are required to write efficient Hadoop MapReduce programs in Java to find the following information:
(i) The 10 most frequent visitors (NAMELAST, NAMEFIRST) to the White House.
(ii) The 10 most frequently visited people (visitee_namelast, visitee_namefirst) in the White House.
(iii) The 10 most frequent visitor-visitee combinations.
(iv) An average number of visitors by month of a year. Say what is the average number of visitors in January over last 4 years. Your program should produce an average number of visitors for 12 months. Consider APPT_START_DATE as the visit date value.


Send your solution in following format:
create a folder with your "name" containing only 4 files
1. Driver Code
2. Mapper Code
3. Reducer Code
4. Output file
copy part-r-00000 output to text file as solution1.txt , solution2.txt...etc

** Make a tar file or tar.gz file of a folder and mail it to "kishorevbhosale@gmail.com"

** If you have github account - share link
Read More