Tuesday, March 28, 2017

Fibonacci number using Dynamic Programming (JAVA)

Recursion is most famous solution for the Fibonacci number. But it's complexity is higher.  It is 2^n. Is what can be better optimal solution. And Answer is Dynamic Programming. We can solve the problem in o(n). But for this we need to use space complexity. We will be saving our previous record to the memory. Let's see..

Initialize our array with certain length

========================================
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
========================================
We will manually assign 1 and 1 to the position 0 and 1 of array. Because we know in Fibonacci Series 1st and 2nd index is 1. 

========================================
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
========================================

now we will iterate through 2 to n and add (n-1) + (n-2) and save it to memory. Which we do is our recursive solution as well. So our array looks like this. 

=========================================
| 1 | 1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
=========================================

we continue iterating it.

=========================================
| 1 | 1 | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
=========================================
                                    :
                                   \/
finally it looks like this

==========================================================
| 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 | 89 | 144 | 233 | 377 | 610 | 987 | 1597 |
==========================================================

Below is Java code: 

 public static void main(String[] args) {

       Scanner in = new Scanner(System.in); // Taking input from console
       int q = in.nextInt();

       int[] arr = new int[q]; // Initializing array

       arr[0]= arr[1] = 1; // Setting 0 and 1st pos to 1

       System.out.print(arr[0]+" "+arr[1]+" "); printing 0th and 1st pos

       for(int i = 2; i<q;i++){  //iterating from 2nd to size

           arr[i] = arr[i-1]+arr[i-2]; // adding last two values

           System.out.print(arr[i]+" "); //Printing value

       }
    }

Wednesday, April 15, 2015

Performing UI Related task from Worker Thread using Handler

This Example shows How to do UI related task from Worker Thread using Handler. Main Thread contains Handler object. Which ever thread creates Handler object receives message from other thread (Handler Handles the Message).


import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;

public class Testing extends Activity {

// Handler Basically does Two task 1) Handle Message in current thread 2)
// Send to other Thread for proccessing
Handler mHandler;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// UI thread creates object of Handler.  
mHandler = new Handler();

new Thread(new Runnable() { // Worker Thread
// Sending Runnable to Handler MessageQueue which will handled in UI Thread
@Override
public void run() {
mHandler.post(new Runnable() { 
@Override
public void run() {
// Showing Toast Message
Toast.makeText(getApplicationContext(), "I am from Worker Thread", Toast.LENGTH_LONG).show();
}
});
}
}).start();  // Starting Thread
}
}
 

Sending message from one worker thread to other worker thread using Handler and Looper (Android)

Below code snippet explains how to send message from one worker thread to another worker thread using Handler, Looper and Message. First worker thread receive message from second thread.



import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

public class Testing extends Activity {

//Handler Basically does Two task 1) Handle Message in current thread 2) Send to other Thread for proccessing
Handler mHandler;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

new Thread(new Runnable() {   // First worker Thread
@Override
public void run() {
                                // Prepare a Massage Queue for Handler so one by one can be processed
Looper.prepare(); 
mHandler = new Handler() { // Handler is associated with current thread
 // Handling Received Messages
                                       @Override
public void handleMessage(Message msg) {  
super.handleMessage(msg);
System.out.println("Recived By " + Thread.currentThread().getName() + " And Msg is: " + msg.arg1);

}
};
Looper.loop();

}
}).start();

new Thread(new Runnable() {   // Second  Worker Thread
@Override
public void run() {
int i = 0;
while (i < 100) {
/*Obtain a Message from Message Pool. It's good practice not to create Message Object but get from System itself. Saves memory.*/
Message msg = Message.obtain();
System.out.println("Sending MSg via: " + Thread.currentThread().getName() + "Data: " + i);
msg.arg1 += i;
mHandler.sendMessage(msg); // Sending Message to 1st worker thread
i++;
}
}
}).start();
}
}

Tuesday, April 14, 2015

Producer Consumer Problem Using Shared Variable

Hi folks, Below JAVA implementation of Producer Consumer using sheared Variable.Producer Produces and Consumer Consumes.

import java.util.Random;

public class ProducerConsumer {

static int food = 0;
static boolean flag = true; // To ensure producer produces first and for toggle
static Thread producer;
static Thread consumer;

public static void main(String... args) {


// Consumer Thread
consumer = new Thread(new Runnable() {
public void run() {
synchronized (producer) {  // locking producer
while (true) {
if (flag == false) {
try {
Thread.sleep(1000); // Delay so it consumes per second
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("I am consuming: "+food);
flag = true;
producer.notify(); // notifying producer
}
}
}
}
});
consumer.start(); // Starting consumer thread

// Producer Thread
producer = new Thread(new Runnable() {
public void run() {
synchronized (consumer) { // locking consumer
while (true) {
if (flag == true) {
try {
Thread.sleep(1000); // Delay so It produces every second
} catch (InterruptedException e) {
e.printStackTrace();
}
food = new Random().nextInt(100); // producing a random number
System.out.println("I am producing: "+food);
flag = false;
consumer.notify(); // Notifying consumer
}
}
}
}
});
producer.start(); // starting Producer Thread

}

}

Saturday, November 29, 2014

CCAvanue payment Integration For Android (With Sample Project)

Hi there!
It's been days that I have posted anything here! But this made me write this post
I was going through Payment Integration in India for mobile apps, specially for android. There are some famous Integration method available such as Paypal, Google Wallet. But These two have problems in India since they are not versatile payment method for every Bank and Indian currency.

At last I found CCAvanue which seems to me a better payment getway option in India. They have cool dashboard and a very effective customer service which is avail 24*7.

CCAvanue has two type of integration for android application, one is seemless and other one is non-seemless. Seemless provides you option to save card information to your database but this requires special PCI Certificate or SAQ based on no hits.

On Request from CCAvanue they provide you the mobile integration kit which carry Android and iOS Project with  two JSP file (One is getRSA.jsp and other one is ccavResponseHandler.jsp) which needs to be host on your register (register with CCAvanue ) website(You don't have to change anything in JSP file).  After hosting these two files you have two url which you will be needing in app.

Since they provide Seemless Integration which is also avail Here. I decided to provide the non-seemless Integration kit which is having three activity  first will take input from user second one will open the webView where user will do the transaction and last one which will show the status whether transaction was successful or failure. Non-seemless Integration kit is available Here, You can download (This is basically reduced code ). You have to change the merchant ID and three URL (Cancel URL, Redirect URL and RSA Url) and you are done. I have commented on code where you need to change things. So,  app flow will be like this

Enter Information ==> Click on Pay Button ==> Open the webView ==> Enter info ==> pay ==> StatusActivity

If Any further query you have, please comment.
Thanks




Thursday, April 18, 2013

Passing an object as parameter to a method

Passing an object as parameter is always a confusing concept. here is a java code given below which might help you understand this concept .

/*========================================*/

public class HelloWorld{
     public static void main(String []args){
       myroom obj = new myroom();
       dadsroom obj1 = new dadsroom();
       obj1.love(obj);
     }
}
 class myroom{
public int x;
    public int y =3;
}
class dadsroom{
 void love(myroom o){
       System.out.println(o.x +"and"+ o.y);
   }
}
/*========================================*/

SHOULD I CALL IT EXPLANATION ? :
 I've created three class in above code, one is HelloWorld which combines the main method, next is myroom, and last one is dadsroom. In main method, I've created an object of myroom "obj" and another object of dadsroom "obj1". dadsroom is having a method love which is receiving object of myroom and then printing instance variable using object of myroom. In main, I've called love method using object of class dadsroom and passing object of myroom  as parameter..

Let's have a formal EXPLANATION:
what i am trying to do is, i am having a template of myroom and also a template of dadsroom through their objects, now I am adding a room which is same as myroom(every thing is same as myroom cause it is instance of myroom) into dadsroom, now a room which is same as myroom is attached with dadsroom, I can access every feature (which was having myroom) through dadsroom. An object of myroom is attached with dadsroom by passing object of myroom.

Sunday, April 14, 2013

More about Activity Life Cycle with an example.

Hey there, Here is an example of Activity life cycle, This will illustrate more about how onCreate(), onStart(), onResume, onPause(), onStop() call in activity Life Cycle, I have Created two activity and given toast in each method, when you navigate the application Toast will pop on the screen as per Activity Life cycle.

<!-- ================First layout (main.xml)=====================-->

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <Button
        android:id="@+id/but"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

<!-- ===================End of main.xml====================== -->


/*=========ActivityLifeCycleActivity (Corrosponding code to main.xml) ========*/
package com.hellboys.act;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class ActivityLifeCycleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Toast.makeText(getBaseContext(), "1 onCreate()",Toast.LENGTH_LONG).show();
       
        Button b1;
        b1 = (Button) findViewById(R.id.but);
        b1.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
Intent intent = new Intent(ActivityLifeCycleActivity.this,abhi.class);
startActivity(intent);
}
});
    }
   
    public void onStart(){
    super.onStart();
    Toast.makeText(getBaseContext(), "1 onStart()",Toast.LENGTH_LONG).show();
    }
   
    public void onResume(){
    super.onResume();
    Toast.makeText(getBaseContext(), "1 onResume()",Toast.LENGTH_LONG).show();
    }
   
    public void onPause(){
    super.onPause();
    Toast.makeText(getBaseContext(), "1 onPause()",Toast.LENGTH_LONG).show();
    }
   
    public void onStop(){
    super.onStop();
    Toast.makeText(getBaseContext(), "1 onStop()",Toast.LENGTH_LONG).show();
    }
}
/*=============End of ActivityLifeCycleActivity=================*/

<!-- ================Second layout (abhi.xml)==================-->

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <AnalogClock
        android:id="@+id/analogClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>
<!-- =====================End of abhi.xml======================= -->


/*=========Second Activity(Java code corresponding to abhi.xml) ========= */
package com.hellboys.act;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
public class abhi extends Activity{
@Override
public void onCreate(Bundle savedInstance){
super.onCreate(savedInstance);
setContentView(R.layout.abhi);
Toast.makeText(getBaseContext(), "2 onCreate()", Toast.LENGTH_LONG).show();
}

public void onStart(){
super.onStart();
Toast.makeText(getBaseContext(), "2 start()", Toast.LENGTH_LONG).show();
}
public void onResume(){
super.onResume();
Toast.makeText(getBaseContext(), "2 onResume()", Toast.LENGTH_LONG).show();
}
public void onPause(){
super.onPause();
Toast.makeText(getBaseContext(), "2 onPause()", Toast.LENGTH_LONG).show();
}
public void onStop(){
super.onStop();
Toast.makeText(getBaseContext(), "2 onstop()", Toast.LENGTH_LONG).show();
}
}
/*=================End of abhi============================*/


/*==========================Do +1 if like ....... ========================*/





Wednesday, March 27, 2013

Sending E-mail through your Application using Mail Clients


It may possible that we need to send E-mail through our Application, The Code is given below for sending E-mail. It uses the mail client installed in Android phone, Oftenly it doesn't work on the emulator because emulator doesn't have a pre-installed mail-client, we need to install E-mail Client first on emulators then this will work on emulator, you can directly run this your phone.

On Emulator Since no client installed, it'll work fine on phone.


<!-- --------------------------------------- XML file------------------------------------------------- -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<TextView
        android:id="@+id/fp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="forget Password?"
        android:layout_gravity="center" />

</LinearLayout>
<!-- ------------------------- End of XML file------------------------------------------------- -->



/*======================== Java File ==================================*/
public class forget extends Activity {
public void onCreate(Bundle savedInstanceActivity ){
super.onCreate(savedInstanceActivity);
setContentView(R.layout.authenticate);

TextView fp = (TextView)findViewById(R.id.fp);
fp.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
try{
Uri uri = Uri.parse("mailto:ashutiwari4@gmail.com");
Intent emailIntent = new Intent(Intent.ACTION_SENDTO,uri);
emailIntent.setType("message/rfc822");
final String aEmailList[]  = {"ashutiwari4@gmail.com"};
emailIntent.putExtra(Intent.EXTRA_EMAIL, aEmailList);
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"Sample Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "this is extra");
startActivity(Intent.createChooser(emailIntent, "Select Email Application"));
}
catch(Exception ex){
Toast.makeText(forget.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
Log.e("SendEmail","Can't send email",ex);
}
}
});
}
}

/*===================== End of Java File ============================*/

Context Menu in Android


Hey friends, In this post I'm gonna explain you how to create List view ?, how to perform specific task on each item selection?, How to create Context Menu and how to perform specific task on  selection of context Item.... So lots of things are there in this post.... So, use it n Enjoy!!

List View  On Single Touch

Context Menu On Long press
/*The Code Goes Here!!*/
<!-- --------------------------------------------------------- XML File ---------------------------------- -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:id="@+id/lay" >

    <ListView
        android:id="@+id/listView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>
</LinearLayout>
<!-- --------------------------------------- End of XML File ------------------------------------------- -->


/*============================== Java File===========================*/
public class Context1Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        final ListView lv = (ListView) findViewById(R.id.listView2);
        String[] list = new String[] {"Home","Office","Office2"};
       
        BaseAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,list);
        lv.setAdapter(adapter);
        /*Registering for context Menu */
        registerForContextMenu(lv);
        /*Setting onItemClick listener so that on clicking, it will work accordingly "single click" */
     
        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener()
        {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
if(lv.getItemAtPosition(arg2)=="Home")
home();
if(lv.getItemAtPosition(arg2)=="Office")
office();
if(lv.getItemAtPosition(arg2)=="Office2"){
office2();
}
}
      });
     
        /* set onClickListner listener on the whole layout(Liner layout) so that whenever user will click on
          screen it will provide option for adding location*/
       
        LinearLayout ll = (LinearLayout)findViewById(R.id.lay);
        //registerForContextMenu(ll); //this can be use for open a context menu by clicking on screen
        ll.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(Context1Activity.this, "linerlayout click", Toast.LENGTH_LONG).show();
}
});
    }
   /*-------------------------Function body for each item in list -------------------------------------*/
    public void home(){
    Toast.makeText(Context1Activity.this,"home single click", Toast.LENGTH_LONG).show();
    }
    public void office(){
    Toast.makeText(Context1Activity.this,"office single click", Toast.LENGTH_LONG).show();
    }
    public void office2(){
    Toast.makeText(Context1Activity.this,"office2 single click", Toast.LENGTH_LONG).show();
    }
   
    /*--------------------------------------------------------------------------------------------------*/
    /* For implementing context menu, two methods should be implement,
     * one is onCreateContextMenu for creating context menu which will add menu
     * other one is OnContextItemSelected for performing action on selecting the items
     */
 
    @Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
     inflater.inflate(R.menu.activity_main, menu); //select layout which should pop up in context menu
 menu.add("Add Location!");
 menu.add("Delete");
 menu.add("Rename");
}
   
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
super.onContextItemSelected(item);
if(item.getTitle()=="Add Location!"){
Addloc();
}
if(item.getTitle()=="Delete"){
Delete();
}
if(item.getTitle()=="Rename"){
Rename();
}
return true;
}
/*----------------------------function body for context menu----------------------------------*/
public void Addloc(){
Toast.makeText(this,"Add location", Toast.LENGTH_LONG).show();
}
public void Delete(){
Toast.makeText(this,"Delete Message", Toast.LENGTH_LONG).show();
}
public void Rename(){
Toast.makeText(this,"Rename message", Toast.LENGTH_LONG).show();
}
/*------------------------------------------------------------------------------------------------*/
}
/*=========================End of Java File===========================*/

Dialog Box with Positive and Negative Button In Android


Android Supports many kind of Dialog Boxes, In this post I tried to explain Dialog Box with a XML EditText, a Negative and a Positive Buttons as shown in Fig., In further post I'll try to explain some other kind of Dialog box. Here is code for Dialog Box --->

/* ========================Code goes Here!! ===============================*/
public class DialogActivity extends Activity {
private static final int DLG_EXAMPLE1=0;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate (savedInstanceState);
setContentView(R.layout.main);

Button b = (Button)findViewById(R.id.ADD_Location );
b.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
showDialog(DLG_EXAMPLE1);
}});
}
// Method for Creating Dialog box
@Override
protected Dialog onCreateDialog(int id ){
switch(id){
case DLG_EXAMPLE1:
return createExampleDialog(); // Function call, body is defined below
default :
return null;
}
}

// This method is used for setting the dialogbox
@Override
protected void onPrepareDialog(int id,Dialog loginPrompt){
switch(id){
case DLG_EXAMPLE1:
final EditText first = (EditText)loginPrompt.findViewById(R.id.rf1);
first.setText(""); // setting the editbox blank
final EditText second = (EditText)loginPrompt.findViewById(R.id.rf2);
second.setText("");
break;
}
}

//Body the function createExampleDialog()
private Dialog createExampleDialog(){
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.userpasslayout, null);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Register Yourself!!");
alert.setIcon(R.drawable.logo);
alert.setMessage("Fill information carefully!");
alert.setView(textEntryView);
AlertDialog loginPrompt = alert.create();

//PositiveButton Onclick Listener
alert.setPositiveButton("Register", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(DialogActivity.this, "So you think!", Toast.LENGTH_LONG).show();
return;
}
});

//NegativeButton onclick Listener
alert.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// NegtiveButton works automatic it will perform cancel of the dialog box;
return;
}
});
return alert.create();
}
/*=====================================================================*/

How to create Option Menu In Android !


In android, we oftentimes need to create Option Menu, Here are two methods we need to override as shown in example given below-

public class DialogActivity extends Activity {

private static final int ADD_LOC = Menu.FIRST;
private static final int CHANGE_PASS = Menu.FIRST+1;

@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate (savedInstanceState);
setContentView(R.layout.main);
}
/*====================== Option menu creation==========================*/
/*------------------------------------menu creation--------------------------------------------*/
@Override
public boolean onCreateOptionsMenu(Menu menu){
menu.add(0,ADD_LOC,0,"Add Location").setIcon(R.drawable.add);
/* 1st argument->group id, ADD_LOC -> item_id, 3rd argument -> appearance of item in menu,
last argument -> Name which will apper on the menu */
menu.add(0,CHANGE_PASS,0,"Rename").setIcon(R.drawable.change);
//AlphabeticShortcut(alphaChar) can be used here for selection item through pressing a key Input
return true;
}
/*-----------------------------------Item Selection-----------------------------------------------*/
@Override
public boolean onOptionsItemSelected(MenuItem item){

switch(item.getItemId()){
case ADD_LOC:
Toast.makeText(DialogActivity.this, "So, YOu can EDIT ?", Toast.LENGTH_LONG).show();
// Your code goes here for case One..., Here I have given a Toast on option item selection
return true;
case CHANGE_PASS:
Toast.makeText(DialogActivity.this, "So, YOu can RENAME ?", Toast.LENGTH_LONG).show();
// Your code goes here for case Two...
return true;
}
return false;
}
/*------------------------------------------------------------------------------------------------------*/
/*====================================================================*/
}

Saturday, March 16, 2013

Start with Android ...


Hey There, I was wondering, If I could help you on android application development... So I am starting a section, This section aims to help you on some Important concepts about Android and more about application development problem, such as basic XML creation, placing listeners in corresponding java files, Context menu creation, Option menu creation, Progress bar creation, Various Dialog Box, DATABASE(SQLite), Mail APIs, Sending Mail without using E-mail Client, Services, Broadcast Receiver, Sending SMS, Sending Text via Bluetooth, Animations, ListView, Splash Screen and much more ...... So just Stay tuned ... .. HaPPy AnDrOId Learning ...... :)       

Saturday, November 3, 2012

How to Download Applications and Software for the Linux and install ‘em:



Hey there , In this post I will talk about Some discipline of installing, Updating, removing  Application on Linux.
       1)      YUM installation
       2)      RPM installation
       3)      APT installation
       4)   MANDRIVA:URPM installation
       5)      TAR BALL installation           
          
     YUM: Yum is an automatic updater and package installer/remover for rpm systems. It automatically computes dependencies and figures out what things should occur to install packages. It makes it easier to maintain groups of machines without having to manually update each one using rpm. Yum has a plugin interface for adding simple features. Yum can also be used from other python programs via its module interface.
For more information visit http://yum.baseurl.org/

INSTALLATION through YUM: First open Terminal of your Linux
      1)      Get super user privilege by Typing “su -” (su [space]-) without quotes and press Enter .Here su stands for sudo.(you can first type sudo[enter] and then type yum links)
      2)       Type yum download link and press Enter. Download starts, it will ask you for installation                                       press  [y][Enter].
      3)      Your application will download and install automatically


RPM Package Manager (RPM): is a package management system. The name RPM variously refers to the .rpm file format, files in this format, software packaged in such files, and the package manager itself. RPM was intended primarily for GNU/Linux distributions; the file format is the baseline package format of the Linux Standard Base.
For more information visit http://rpm.org/

INSTALLATION through RPM: For installing a software package, you use the rpm command with -i option (which stands for "install"). For example,
1).To install an RPM package called software-2.3.4.rpm:
# rpm -i software-2.3.4.rpm
2).If you already have some version installed on your system and want to upgrade it to the new version, you use -U option instead (which stands for "upgrade"). For example, if you have software-2.3.3.rpm installed and want to upgrade it:
# rpm -U software-2.3.4.rpm
3).If you know the needed files are there and RPM is just being stupid, you can ignore the dependencies. Use the --nodeps option if you want to tell RPM not to check any dependencies before installing the package:
# rpm -i software-2.3.4.rpm –nodeps
4).To remove software that was installed with RPM, you use the -e option (which stands for "erase"):
# rpm -e software-2.3.4
5). As you already know, the RPM database contains a list of all installed RPM packages on your system. You can query this database to get info of the packages on your Linux system. To query a single package, you use the -q option. For example, to query a package whose name is "software":
# rpm -q software
6). If you want a list of all packages installed on your system, you'll have to query all with -qa:
# rpm –qa
7). if you're looking for packages whose names contain a specific word, you can use grep for finding those packages. For example, to get a list of all installed RPM packages whose names contain the word "kde", you could do something like this:
# rpm -qa | grep kde

APT INSTALATION: The Advanced Packaging Tool, or APT, is a free user interface that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants.apt-get is so easy because it not only keeps track of what packages are installed, but also what other packages are available. It will even download them from the Internet for you (if properly configured).

            1).To install apt package
apt-get install ${packagename}
2).To remove software is just as easy:
Apt-get remove ${packagename}
3). APT keeps a local database on your hard drive with a list of all available packages and where to find them. This database needs to be explicitly updated. To update the APT database:
Apt-get update
4). For upgrading all package:
Apt-get upgrade


Mandriva: urpm INSTALLATION:
Mandriva Linux (formerly Mandrake and Connectiva) has a toolset similar to APT called urpmi.

1). To install software:
urpmi  ${packagename}
2). To remove software:
urpme ${packagename}
3). To update the local database:
urpmi.update –a
4). To install security updates and bug fix:
Urpmi –auto-select




Tar Balls INSTALLATION: A tar ball is a (usually compressed) archive of files, similar to a Zip file on Windows or a Sit on the Mac. Tar balls come in files that end in .tar, .tar.gz, .tgz or something along these lines. To unpack a tar ball, use this command.

tar –xyvf ${packagename}.tar.gz
-:Enjoy Open Source, Happy downloading and installation :-