What is TCPMon ?


TCPMon is a utility that allows the user to monitor the messages passed along in TCP based conversation. It is based on a swing UI and works on almost all platforms that Java supports.It has originally being part of Axis1 and now stands as an independent project.

TCPMon can be used in several ways. sush as : 

  1. As an Explicit Intermediate
  2. As a Request Sender for Web Services
  3. As a Proxy
  4. Slow Connection Simulation
  5. HTTP Proxy support
For more information refer page about TCPMon in Apache web site : TCPMon

How to install TCPMon on Ubuntu.


Installing TCPMon on Ubuntu is quite easy task. What you have to do is just follow the following steps. 

1.Download the zip package from Apache TCPMon release (Only the Binary Version)
2.Go to you dowload directory and copy the zip file to your preferred destination
3.Open terminal and nevigate to the folder where you copy the zip file
4.Type in the termina " unzip tcpmon-1.0-bin.zip " and unzip it
  1. type cd tcpmon-1.0-bin/build and hit enter
  2. type chmod 777 tcpmon.sh and hit enter
7.finally type ./tcpmon.sh Thats it

When you are hoping to work with Google Maps Android  API v2 you may require SHA1 key. In this post i`m going to tell you how to obtain SHA1 Key from you machine.

To get the fingerprint(SHA1 ) just follow the below instructions :

Step 1 :

Go to - C:\Program Files\Java\jdk1.7.0_25\bin

Step 2 :

Inside the bin folder there is a .exe file which is named as "jarsigner.exe". Double click on the .exe file and run it.

Step 3:

open command prompt (press Windows Key + R then type "cmd" without quotations in the appearing dialogue box and then press Enter Key).

then type the code sniff below :

cd C:\Program Files\Java\jdk1.7.0_25\bin


then again type on cmd :

keytool -list -keystore "C:/Documents and Settings/Your Name/.android/debug.keystore"

Step 4:

Then it will ask for Keystore password now. The default password if "android" type and enter


Now Your are Done. You will have a Key Like Below :)



Tree Traversal 



Identify Tree Elements First..



Introduction..

       Here we are going to talk about
Tree traversal. In computer science, that refers to the process of visiting each node in a tree structure,exactly once, in a systematic way. As in the above diagram nodes are indicated as circles. These kind of traversals are classified by the order in which the nodes are visited. In this post we are going to talk about traversing using algorithms in binary trees. this processes are not only true for the binary trees. Those can be generalized to the other trees as well (i.e ternary trees.).

Traversing in a Binary Tree..
            To traverse a binary tree there exist several different ways. Starting at the root of a binary tree( First node of the tree), there are three main steps that can be performed and the order in which they are performed  defines the traversal type. These steps (in no particular order) are: performing an action on the current node (referred to as "visiting" the node), traversing to the left child node, and traversing to the right child node.

Recursion and Co-Recursion..

Recursion..

Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem (as opposed to iteration). The approach can be applied to many types of problems, and recursion is one of the central ideas of computer science.


In computer sciencecorecursion is a type of operation that is dual to recursion. Whereas recursion works analytically, starting on data further from a base case and breaking it down into smaller data and repeating until one reaches a base case, corecursion works synthetically, starting from a base case and building it up, iteratively producing data further removed from a base case. Put simply, corecursive algorithms use the data that they themselves produce, bit by bit, as they become available, and needed, to produce further bits of data. Some authors refer to this as generative recursion.           

Resource : http://en.wikipedia.org/wiki/Corecursion

Traversing a tree can be done in several ways. Normally how we do is we use iterating method to visit all the nodes in the tree.  Because from a given node there is more than one possible next node (it is not a linear data structure), then, assuming sequential computation (not parallel), some nodes must be deferred – stored in some way for later visiting. We do this using either stack or a queue. those data structures have implemented using  LIFO (Last In First Out) and FIFO (First inf Last Out) principles. As we know tree is a recursively defined data structure. Its known as self-referential data structures.  In a tree traversing can  be done in either recursion or either in corecursion manner. Usually we use recursion to traverse the tree.

There are two strategies that we used to traverse a tree. One is call Depth First and Other one is call the Breadth First.
For the purpose of illustration, it is assumed that left nodes always have priority over right nodes. This ordering can be reversed as long as the same ordering is assumed for all traversal methods. Depth First Search can be easily implemented using a stack where as the breadth first traversal can be easily implemented using a queue.

Depth-first traversal is easily implemented via a stack, including recursively (via the call stack), while breadth-first traversal is easily implemented via a queue, including corecursively. For the purpose of illustration, it is assumed that left nodes always have priority over right nodes. This ordering can be reversed as long as the same ordering is assumed for all traversal methods.

Depth First 

In depth first traversal there are three main types of traversal methods are exist. Namely

  1. Pre- Order Traversal 
  2. In-Order Traversal
  3. Post- Order Traversal
For a binary tree they are defined in the following way.

Pre- Order Traversal

 In pre-order traversal we follow 3 steps as listed below.
  1. Visit the root
  2. Traverse the left subtree.
  3. Traverse  the right subtree.
In-Order Traversal

As pre-order traversal there also exist 3 methods to traverse the tree.
  1. Traverse the left subtree
  2. Visit the root
  3. Traverse the right subtree
Post-Order Traversal
  1. Traverse the left subtree
  2. Traverse the right subtree
  3. Visit the root
Through the following examples you may be able to figure out how we visit a binary tree in each of above mentioned method.





Breadth First 

Any tree can also be traversed in level-order, where we visit every node on a level before going to a lower level.

eg : Traverses the tree or graph level-by-level, visiting the nodes of the tree above in the order a b c d e f g h i j k.




















  • Learn About Java Classes :

Ok before we go deep in to class declaration and so topic.. I believe its better to have a proper understanding about the rules associated with declaring classes.

There can only be one public class per source code file.

 Comments can appear at the beginning or end of any line in the source code file.

 If there is a public class in a file, the name of the file must match the same of the public class. For  example : a class declared as public class Dog {} must be in a source code file names Dog.java

  If the class is part of a package, the package statement must be the first line in the source code    file, before ant import statements that may be present.

 If there are import statements, they must go between the package statement(if there is one) and the  class declaration. If there isn't a package statement,then the import statement(s) must be the first line(s)           in the source code file.If there are no package or import statements, the class declaration must be the             first line in the source code file

import and package statements apply to all classes within a source code file.In other words, there's no            way to declare multiple classes in a file and have them in different packages, or use different imports.

 A file can have more than one nonpublic class.

 Files with no public classes can have a name that does not match any of the classes in the file.

Ok now you are equipped for the knowing how to declare a classes in your code. When you want to declare a class i  you code you now use  class key word. as well as you need to add {} after you declaration of the class to indicate the borders of the relevant class. All of the variables , methods (Those will learn later. ) which are relevant to those classes are will be reside in those {} brackets.

Ex :  class dog{} , class man{}


For a declared class you can add access modifiers in front of it. Those are also be the key word of java. Such as public , private and protected. By default any declared class have access modifier default on it. But we don`t indicate that in the code. 
Examples with Access Modifiers : 

public class dog { } ,  private class man { } ,  protected class pen { }

Not only the access modifies you can use Non - Access modifiers as well with a class declaration. Such as strictfp , abstract , final
Examples with Non Access Modifiers :
final class dog {} , abstract class man {}


Now lets move on to class access modifiers..
Class Access.. 

What is mean to access a class?. When we say code from one class (class A) has access to another class (class B) , it means class A can do one of three things.

  1. Create an instance of class B
  2. Extend  class B (that means became a sub class of class B)
  3. Access certain methods and variables with in the class B, depending on the access control of those.
The easiest way to understand about the access is consider the access as visibility. For a example If class A can`t see class B, class A can`t access any of those variables and the methods in class B.

Now Let`s looking to each of the access modifies separately. 

If we are coding a some program with several classes basically we first set up a package. If you use Netbeans for coding that task will be done for you automatically. There can be packages in side packages as well. As well as all of the classes that we create must belong to one of package that you are working on. Each package can have one or more classes. See below figure.


As you can see above there is a package call accounts. (You may not familer with this diagrams. You can learn about UML class diagram representation here) inside that package there are 3 classes called BankAccount  , CheckingAccount and SavingsAccount. As well as in each class represantation you can clearly see variable and methods are separated by a line in that each class representing box. Since those Checking and Savings accounts are the two types of Bank Account we can extend them from its major class BankAccount.  we called it we extend SavingsAccount class from BankAccount class. (we will see how to a class from its super class (parent class) later) One of major advantage of extending parent class is we don`t need to implement same methods and varibals over and over which are common to all of them. In the above diagram you can clearly see that in the BankAccount class we have used a method call withdrawal()
where as which uses same method in the lower level classes. Tough i drew those in this diagram in actual code we don`t want to implement those methods since we do extending the parent class. By extending parent we get all of methods in the parent class by default.

Ok i am pretty sure that now you have basic idea about classes and packages. Ok now lets move to our new session called Access Controls.

There are number of access modifiers to set access level for classes, variables, methods and constructors. There are four major access levels in java. Such as ;

  • Visible to the package only. the default. No modifiers are needed
  • Visible to the class only (private)
  • Visible to the world (public)
  • Visible to the package and all sub classes (protected)
The first data column indicates whether the class itself has access to the member defined by the access level. As you can see, a class always has access to its own members. The second column indicates whether classes in the same package as the class (regardless of their parentage) have access to the member. The third column indicates whether sub classes of the class declared outside this package have access to the member. The fourth column indicates whether all classes have access to the member.

Access levels affect you in two ways. First, when you use classes that come from another source, such as the classes in the Java platform, access levels determine which members of those classes your own classes can use. Second, when you write a class, you need to decide what access level every member variable and every method in your class should have.


The following table shows where the members of the dog class are visible for each of the access modifiers that can be applied to them.










        Getting a Git Repository


        Well i believe that you are familiar with what is Git Hub :P  I was kidding. Without knowing what is Git Hub you don`t want to mess up with Cloning a Git Repository right ??. Ok there are two ways to Getting a Git Hub Repository.
        1. Initializing a Repository in an Existing Directory.
        2. Cloning an Existing Repository.
        Initializing a Repository in an Existing Directory.

        If you’re starting to track an existing project in Git, you need to go to the project’s directory and type
        $ git init
        
        This creates a new subdirectory named .git that contains all of your necessary repository files — a Git repository skeleton. At this point, nothing in your project is tracked yet. (See Chapter 9 for more information about exactly what files are contained in the .git directory you just created.)
        If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit. You can accomplish that with a few git addcommands that specify the files you want to track, followed by a commit:
        $ git add *.c
        $ git add README
        $ git commit -m 'initial project version'
        
        We’ll go over what these commands do in just a minute. At this point, you have a Git repository with tracked files and an initial commit.

        Cloning an Existing Repository
        If you want to get a copy of an existing Git repository — for example, a project you’d like to contribute to — the command you need is git clone. If you’re familiar with other VCS systems such as Subversion, you’ll notice that the command is clone and not checkout. This is an important distinction — Git receives a copy of nearly all data that the server has. Every version of every file for the history of the project is pulled down when you run git clone. In fact, if your server disk gets corrupted, you can use any of the clones on any client to set the server back to the state it was in when it was cloned (you may lose some server-side hooks and such, but all the versioned data would be there — see Chapter 4 for more details).
        You clone a repository with git clone [url]. For example, if you want to clone the Ruby Git library called Grit, you can do so like this:
        $ git clone git://github.com/schacon/grit.git
        
        That creates a directory named grit, initializes a .git directory inside it, pulls down all the data for that repository, and checks out a working copy of the latest version. If you go into the new gritdirectory, you’ll see the project files in there, ready to be worked on or used. If you want to clone the repository into a directory named something other than grit, you can specify that as the next command-line option:
        $ git clone git://github.com/schacon/grit.git mygrit
        
        That command does the same thing as the previous one, but the target directory is called mygrit.
        Git has a number of different transfer protocols you can use. The previous example uses the git://protocol, but you may also see http(s):// or user@server:/path.git, which uses the SSH transfer protocol. Chapter 4 will introduce all of the available options the server can set up to access your Git repository and the pros and cons of each.
         
         Let`s start with Java Basic Concepts :


        Before moving for java programming we must understand the basic concepts of the Java Language.Most Java programs use a collection of objects of many different types. Such as Class, Object , State , Behavior. Let`s looking in to each of them listed above.





        Class : A template that describes the kinds of state and behavior that objects of its type support.

        Object :At runtime, when the Java Virtual Machine (JVM) encounters the new keyword, it will use the appropriate class to make an object which is an instance of that class. That object will have its own state, and access to all of the behaviors defined by its class.

        State(instance variables) : Each object (instance of a class) will have its own unique set of instance variables as defined in the class. Collectively, the values assigned to an object's instance variables make up the object's state.

        Behavior(methods) : When a programmer creates a class, she creates methods for that class. Methods are where the class' logic is stored. Methods are where the real work gets done. They are where algorithms get executed, and data gets manipulated.

        What are Java Identifiers..

         
        All the Java components that we are talking about(classes, variables, methods.. etc) need name to identify them uniquely. In java those names are called identifiers.

        What are Legal Identifiers...
        Technically, legal identifiers must be composed of only Unicode characters, numbers, currency symbols, and connecting characters (like underscores). The exam doesn't dive into the details of which ranges of the Unicode character set are considered to qualify as letters and digits. So, for example, you won't need to know that Tibetan digits range from \u0420 to \u0f29. Here are the rules you do need to know:

        ■ Identifiers must start with a letter, a currency character ($), or a connecting character such as the     underscore ( _ ). Identifiers cannot start with a number!

        ■ After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.

        ■ In practice, there is no limit to the number of characters an identifier can contain.

        ■ You can't use a Java keyword as an identifier. Table 1-1 lists all of the Java keywords including one new one for 5.0, enum.

        ■ Identifiers in Java are case-sensitive; foo and FOO are two different identifiers.

        Examples of legal and illegal identifiers follow, first some legal identifiers:

        int _a;
        int $c;
        int ______2_w;
        int _$;
        int this_is_a_very_detailed_name_for_an_identifier;

        The following are illegal (it's your job to recognize why):

        int :b;
        int -d;
        int e#;
        int .f;
        int 7g;

        What are Java Keywords..

        Like all programming languages, Java has a set of built-in keywords. These keywords must not be used as identifiers (names of the Java Components). 

        Below i have listed many of the available Java Keywords.
        abstractcontinuefornewswitch
        assert***defaultgoto*packagesynchronized
        booleandoifprivatethis
        breakdoubleimplementsprotectedthrow
        byteelseimportpublicthrows
        caseenum****instanceofreturntransient
        catchextendsintshorttry
        charfinalinterfacestaticvoid
        classfinallylongstrictfp**volatile
        const*floatnativesuperwhile
        *not used
        **added in 1.2
        ***added in 1.4
        ****added in 5.0

        As well as if we are going to be a good Java Programmer we must adder to the Oracle Java Coding Conventions. That means all of the names(Identifiers) should follow the its naming conventions. It is not a must, but as programmers we must follow it.

        Java Naming Conventions..

        When choosing a name for an identifier make sure it's meaningful. For instance, if your program deals with customer accounts then choose names that make sense to dealing with customers and their accounts (e.g., customerName, accountDetails). Don't worry about the length of the name. A longer name that sums up the identifier perfectly is preferable to a shorter name that might be quick to type but ambiguous.

        A Few Words About Cases..
        Using the right letter case is the key to following a naming convention.
        • Lower Case is the wher all the letters in a word are written without any caoitalization(eg : while,  if, mypackage)
        • Uppercase is where all the letters in a word are written in capitals. When there are more than two words in the name use underscores to separate them (e.g., MAX_HOURS,  FIRST_DAY_OF_WEEK).
        • Camel Case  (also known as Upper CamelCase) is where each new word begins with a capital letter (e.g., CamelCase, CustomerAccount, PlayingCard).
        • Mixed Case (also known as Lower CamelCase) is the same as CamelCase except the first letter of the name is in lowercase (e.g., hasChildren, customerFirstName, customerLastName).
        Java Naming Conventions..


      • Packages: Names should be in lowercase. With small projects that only have a few packages it's okay to just give them simple (but meaningful!) names:
         package pokeranalyzer
         package mycalculator 
        In software companies and large projects where the packages might be imported into other classes, the names will normally be subdivided. Typically this will start with the company domain before being split into layers or features:
         package com.mycompany.utilities
         package org.bobscompany.application.userinterface 
      • Classes: Names should be in CamelCase. Try to use nouns because a class is normally representing something in the real world:
         class Customer
         class Account 
      • Interfaces: Names should be in CamelCase. They tend to have a name that describes an operation that a class can do:
         interface Comparable
         interface Enumerable 
        Note that some programmers like to distinguish interfaces by beginning the name with an "I":
         interface IComparable
         interface IEnumerable 
      • Methods: Names should be in mixed case. Use verbs to describe what the method does:
         void calculateTax()
         string getSurname() 
      • Variables: Names should be in mixed case. The names should represent what the value of the variable represents:
         string firstName
         int orderNumber 
        Only use very short names when the variables are short lived, such as in for loops:
         for (int i=0; i<20;i++)
         {
            //i only lives in here
         } 
      • Constants: Names should be in uppercase.
         static final int DEFAULT_WIDTH
         static final int MAX_HEIGHT 

      • What is Java ???? 

        Java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!

        Yes i  want to learn Java What Should i Do?? 

        Good if you are interested in learning java. first of all you must need to have a java environment to test and run your codes. So that you are require to establish such a environment around you. If you are very new for programming you may not heard of term called JVM (Java Virtual Machine)

        Yes i`m new to Java and new to Programming tell me what the hell is that?? :O 

        Yeah ok i`ll explain you. Java is a platform independent language. that means  p
        rograms that written in Java are interpreted by Java itself, which is installed a platform. The language is platform-independent because programs written in it will work on any computer that has Java installed on it, regardless of operating system. To establish such environment we need to install the java to what ever the plat form that we are in. That facility will be provided by the JVM once you download and install it in to your machine.

        Where can i download JVM??

        You can download JVM from here : Download Link to JVM

        I have download and installed the java. What i have to do now?

        Hmm.. well now you are ready to code java programs. Here i`m going to tell you how to write java programs using Netbeans IDE. 



        What is that mean by 'Netbeans IDE'

        Netbeans is a software which provides you better coding facilities for your programs.
        IDE stands for 'Integrated Development Environment'

        That means that Netbeans Software provide us a Development Environment to Develop our Java Programs.

        You can download and install Netbeans Here : Download Link to Netbeans


        Ok now i`m pretty sure that you are equipped with latest JVM and the Netbeans Software.

        Lets Start Our Java Learning Part Form Next Post.