Monday, November 21, 2011

15 GREAT THOUGHTS BY CHANAKYA


1) "Learn from the mistakes of others... you can...'t live long enough to make them all yourselves!!"


2)"A person should not be too honest. Straight trees are cut first and Honest people are screwed first."


3)"Even if a snake is not poisonous, it should pretend to be venomous."


4)"There is some self-interest behind every friendship. There is no friendship without self-interests. This is a bitter truth."


5)" Before you start some work, always ask yourself three questions - Why am I doing it, What the results might be and Will I be successful. Only when you think deeply and find satisfactory answers to these questions, go ahead."


6)"As soon as the fear approaches near, attack and destroy it."


7)"The world's biggest power is the youth and beauty of a woman."


8)"Once you start a working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest."


9)"The fragrance of flowers spreads only in the direction of the wind. But the goodness of a person spreads in all direction."


10)"God is not present in idols. Your feelings are your god. The soul is your temple."


11) "A man is great by deeds, not by birth."


12) "Never make friends with people who are above or below you in status. Such friendships will never give you any happiness."


13) "Treat your kid like a darling for the first five years. For the next five years, scold them. By the time they turn sixteen, treat them like a friend. Your grown up children are your best friends."


14) "Books are as useful to a stupid person as a mirror is useful to a blind person."


15) "Education is the Best Friend. An Educated Person is Respected Everywhere. Education beats the Beauty and the Youth."

Tuesday, November 8, 2011

Choose your BOSS carefully


There was once a washer man who had a donkey and a dog. One night when the whole world was sleeping, a thief broke into the house, the washer man was fast asleep too but the donkey and the dog were awake. The dog decided not to bark since the master did not take good care of him and wanted to teach him a lesson. The donkey got worried and said to the dog that if he doesn't bark, the donkey will have to do something himself. The dog did not change his mind and the donkey started braying loudly. Hearing the donkey bray, the thief ran away, the master woke up and started beating the donkey for braying in the middle of the night for no reason. Moral of the story “One must not engage in duties other than his own"

Now take a new look at the same story... The washer man was a well educated man from a premier management institute. He had the fundas of looking at the bigger picture and thinking out of the box. He was convinced that there must be some reason for the donkey to bray in the night.. He walked outside a little and did some fact finding, applied a bottom up approach, figured out from the ground realities that there was a thief who broke in and the donkey only wanted to alert him about it. Looking at the donkey's extra initiative and going beyond the call of the duty, he rewarded him with lot of hay and other perks and became his favorite pet.
The dog's life didn't change much, except that now the donkey was more motivated in doing the dog's duties as well. In the annual appraisal the dog managed "ME" (Met Expectations) . Soon the dog realized that the donkey is taking care of his duties and he can enjoy his life sleeping and lazing around. The donkey was rated as “star performer". The donkey had to live up to his already high performance standards. Soon he was over burdened with work and always under pressure and now is looking for a NEW JOB ... !!!!

Thursday, November 3, 2011

Tunneling

Handling the general case of making two different networks interwork is exceedingly difficult. However, there is a common special case that is manageable. This case is where the source and destination hosts are on the same type of network, but there is a different network in between. As an example, think of an international bank with a TCP/IP-based Ethernet in Paris, a TCP/IP-based Ethernet in London, and a non-IP wide area network (e.g., ATM) in between, as shown in Fig. given below

Tunneling a packet from Paris to London.













The solution to this problem is a technique called tunneling. To send an IP packet to host 2, host 1 constructs the packet containing the IP address of host 2, inserts it into an Ethernet frame addressed to the Paris multiprotocol router, and puts it on the Ethernet. When the multiprotocol router gets the frame, it removes the IP packet, inserts it in the payload field of the WAN network layer packet, and addresses the latter to the WAN address of the London multiprotocol router. When it gets there, the London router removes the IP packet and sends it to host 2 inside an Ethernet frame.
The WAN can be seen as a big tunnel extending from one multiprotocol router to the other. The IP packet just travels from one end of the tunnel to the other, snug in its nice box. It does not have to worry about dealing with the WAN at all. Neither do the hosts on either Ethernet. Only the multiprotocol router has to understand IP and WAN packets. In effect, the entire distance from the middle of one multiprotocol router to the middle of the other acts like a serial line.
An analogy may make tunneling clearer. Consider a person driving her car from Paris to London. Within France, the car moves under its own power, but when it hits the English Channel, it is loaded into a high-speed train and transported to England through the Chunnel (cars are not permitted to drive through the Chunnel). Effectively, the car is being carried as freight, as depicted in Fig. given below. At the far end, the car is let loose on the English roads and once again continues to move under its own power. Tunneling of packets through a foreign network works the same way.


Tunneling a car from France to England.











(Courtesy:-A.S.Tanenbaum)

Thursday, October 6, 2011

Asynchronous Transfer Mode(ATM)

Introduction:-
ATM is a cell-switching and multiplexing technology that combines the benefits of circuit switching (guaranteed capacity and constant transmission delay) with those of packet switching (flexibility and efficiency for intermittent traffic). It provides scalable bandwidth from a few megabits per second (Mbps) to many gigabits per second (Gbps). Because of its asynchronous nature, ATM is more efficient than synchronous technologies, such as time-division multiplexing (T.D.M.). With TDM, each user is assigned to a time slot, and no other station can send in that time slot. If a station has a lot of data to send, it can send only when its time slot comes up, even if all other time slots are empty. If, however, a station has nothing to transmit when its time slot comes up, the time slot is sent empty and is wasted. Because ATM is asynchronous, time slots are available on demand with information identifying the source of the transmission contained in the header of each ATM cell.

Evolution:-
Asynchronous transfer mode has not been on the market for a long time in comparison to other technologies . How ever credit is due to researchers of bell laboratories for their work in this this area long before it came to forefront of the media attention in late 1980's. ATM actually began to take shape in the late 1980's and the driving force behind the development was a need for a fast switching technology that supports data ,voice, video and multimedia in general.Now various types of ATM implementation can be done

Architecture
We can consider in ATM architecture following 3 points :-
1)ATM virtual connection
2)Cell Structure
3)ATM Reference Model

ATM Virtual Connections
ATM networks are fundamentally connection oriented, which means that a virtual channel (VC) must be set up across the ATM network prior to any data transfer. (A virtual channel is roughly equivalent to a virtual circuit.)
Two types of ATM connections exist: virtual paths, which are identified by virtual path identifiers, and virtual channels, which are identified by the combination of a VPI and a virtual channel identifier (VCI).
A virtual path is a bundle of virtual channels, all of which are switched transparently across the ATM network on the basis of the common VPI. All VCIs and VPIs, however, have only local significance across a particular link and are remapped, as appropriate, at each switch.
A transmission path is a bundle of VPs as shown below:







CELL Architecture

ATM is based on the switching of 53-byte cells, in which each cell consists of a 5-byte header and a payload of 48 bytes of information. Figure 14.1 illustrates the format of the ATM cell, including the explosion of its 5-byte header to indicate the fields carried in the header.



















Figure : The 53-byte ATM cell.
The 4-bit Generic Flow Control (GFC) field is used as a mechanism to regulate the flow of traffic in an ATM network between the network and the user. The use of this field is currently under development. As we will shortly note, ATM supports two major types of interfaces: Network-to-User (UNI) and Network-to-Network (NNI). When a cell flows from the user to the network or from the network to the user, it will carry a GFC bit value. However, when it flows within a network or between networks, the GFC field is not used. Instead of being wasted, its space can be used to expand the length of the Virtual Path Identifier field.
The 8-bit Virtual Path Identifier (VPI) field represents one half of a two-part connection identifier used by ATM. This field identifies a virtual path that can represent a group of virtual circuits transported along the same route. Although the VPI is eight bits long in a UNI cell, the field expands to 12-bit positions to fill the Generic Flow Control field in an NNI cell. It is described in more detail later in this chapter.
The Virtual Channel Identifier (VCI) is the second half of the two-part connection identifier carried in the ATM header. The 16-bit VCI field identifies a connection between two ATM stations communicating with one another for a specific type of application. Multiple virtual channels (VCs) can be transported within one virtual path. For example, one VC could be used to transport a disk backup operation, while a second VC is used to transport a TCP/IP-based application. The virtual channel represents a one-way cell transport facility. Thus, for each of the previously described operations, another series of VCIs is established from the opposite direction. You can view a virtual channel as an individual one-way end-to-end circuit, whereas a virtual path that can represent a collection of virtual channels can be viewed as a network trunk line. After data is within an ATM network, the VPI is used to route a common group of virtual channels between switches by enabling ATM switches to simply examine the value of the VPI. Later in this chapter, you will examine the use of the VCI.
The Payload Type Identifier (PTI) field indicates the type of information carried in the 48-byte data portion of the ATM cell. Currently, this 3-bit field indicates whether payload data represents management information or user data. Additional PTI field designators have been reserved for future use.
The 1-bit Cell Loss Priority (CLP) field indicates the relative importance of the cell. If this field bit is set to 1, the cell can be discarded by a switch experiencing congestion. If the cell cannot be discarded, the CLP field bit is set to 0.
The last field in the ATM cell header is the 8-bit Header Error Control field. This field represents the result of an 8-bit Cyclic Redundancy Check (CRC) code, computed only over the ATM cell header. This field provides the capability for detecting all single-bit errors and certain multiple-bit errors that occur in the 40-bit ATM cell header.

The ATM Protocol Reference Model
Three layers in the ATM architecture form the basis for the ATM Protocol Reference model, illustrated in Figure 14.5. Those layers are the Physical layer, the ATM layer, and the ATM Adaptation layer.









Figure : The ATM protocol suite.
The Physical Layer
As indicated in Figure 14.5, the lowest layer in the ATM protocol is the Physical layer. This layer describes the physical transmission of information through an ATM network. It is not actually defined with respect to this new technology. The absence of a Physical layer definition results from the design goal of ATM to operate on various physical interfaces or media types. Thus, instead of defining a specific Physical layer, ATM depends on the Physical layers defined in other networking protocols. Types of physical media specified for ATM include shielded and unshielded twisted-pair, coaxial cable, and fiber-optic cable, which provide cell transport capabilities ranging from a T1 rate of 1.544Mbps to a SONET range of 622Mbps.
The ATM Layer
The ATM layer represents the physical interface between the ATM Adaptation layer (AAL) and the Physical layer. Thus, the ATM layer is responsible for relaying cells from the AAL to the Physical layer for transmission, and in the opposite direction from the Physical layer to the AAL for use in an endpoint. When transporting cells to the Physical layer, the ATM layer is responsible for generating the five-byte cell header for each cell. When receiving cells from the Physical layer, the ATM layer performs a reverse operation, extracting the five-byte header from each cell.
The actual manner by which the ATM layer performs its relaying function depends on the location of the layer at a switch or at an endpoint. If the ATM layer is located in an endpoint, it receives a stream of cells from the Physical layer and transmits either cells with new data or empty cells if there is no data to send to the AAL. When located in a switch, the ATM layer is responsible for determining where incoming cells are routed and for multiplexing cells by placing cells from individual connections into a single-cell stream.
The ATM Adaptation Layer
The ATM Adaptation layer (AAL) represents the top layer in the ATM Protocol model. This layer is responsible for providing an interface between higher-layer protocols and the ATM layer. Because this interface normally occurs based on a voice, data, or video application accessing an ATM network, the operations performed by the AAL occur at endpoints and not at ATM switches. Thus, the AAL is shown in Figure 14.5 to reside at ATM endpoints.

ATM services in Market
When purchasing ATM service, you generally have a choice of four different types of service:
constant bit rate (CBR): specifies a fixed bit rate so that data is sent in a steady stream. This is analogous to a leased line.
variable bit rate (VBR): provides a specified throughput capacity but data is not sent evenly. This is a popular choice for voice and videoconferencing data.
available bit rate (ABR): provides a guaranteed minimum capacity but allows data to be bursted at higher capacities when the network is free.
unspecified bit rate (UBR): does not guarantee any throughput levels. This is used for applications, such as file transfer, that can tolerate delays.

Advantages of the ATM

ATM supports voice, video and data allowing multimedia and mixed services over a
single network.
High evolution potential, works with existing, legacy technologies
Provides the best multiple service support
Supports delay close to that of dedicated services
Supports the broadest range of burstiness, delay tolerance and loss performance through the implementation of multiple QoS classes
Provides the capability to support both connection-oriented and connectionless traffic using AALs
Able to use all common physical transmission paths like SONET.
Cable can be twisted-pair, coaxial or fiber-optic
Ability to connect LAN to WAN
Legacy LAN emulation
Efficient bandwidth use by statistical multiplexing
Scalability
Higher aggregate bandwidth
High speed Mbps and possibly Gbps

Disadvantages of the ATM
Flexible to efficiency’s expense, at present, for any one application it is usually possible to find a more optimized technology
Cost, although it will decrease with time
New customer premises hardware and software are required
Competition from other technologies -100 Mbps FDDI, 100 Mbps Ethernet and fast Ethernet
Presently the applications that can benefit from ATM such as multimedia are rare
The wait, with all the promise of ATM’s capabilities many details are still in the standards process

Saturday, August 6, 2011

C++ Destructors Vs. Java finalize()


When you move from C++ to Java, one of the more subtle, yet important issues you will face is the difference between a C++ destructor and a Java finalize() method. Although similar in many respects, their actual operation is distinctively different. Let's begin by reviewing the purpose and effect of a C++ destructor and the Java finalize() method. In C++, when an object goes out of scope, it is destroyed. Just prior to its destruction, its destructor function is called (if it has one). This is a hard-and-fast rule. There are no exceptions. Let's look more closely at each part of this rule:
  1. Every object is destroyed when it goes out of scope. Thus, if you declare a local object inside a function, when that function returns, that local object is automatically destroyed. The same goes for function parameters and for objects returned by functions.
  2. Just before destruction, the object's destructor is called. This happens immediately, and before any other program statements will execute. Thus, a C++ destructor will always execute in a deterministic fashion. You can always know when and where a destructor will be executed.

In Java, the tight linkage of the destruction of an object and the calling of its finalize() method does not exist. In Java, objects are not explicitly destroyed when they go out of scope. Rather, an object is marked as unused when there are no longer any references pointing to it. Even then, the finalize() method will not be called until the garbage collector runs. Thus, you cannot know precisely when or where a call to finalize( ) will occur. Even if you execute a call to gc( ) (the garbage collector), there is no guarantee that finalize( ) will immediately be executed.

While the deterministic behavior of a C++ constructor and the somewhat probabilistic aspect of finalization are of little concern in most cases, they will have an impact on others. For example, consider the following C++ program:

// This C++ program can call f() indefinitely.


#include <iostream>

#include <cstdlib>

using namespace std;

const int MAX = 5;

int count = 0;

class X {

public:

// constructor


X() {

if(count<MAX) {

count++;

}

else {

cout << "Error — can't construct";

exit(1);

}

}

// destructor

~X() {

count—;

}

};

void f()

{

X ob; // allocate an object

// destruct on way out

}

int main()
{

int i;

for(i=0; i < (MAX*2); i++) {

f();

cout << "Current count is: " << count

<< endl;

}

return 0;

}


Here is the output generated by this program:

Current count is: 0

Current count is: 0

Current count is: 0

Current count is: 0

Current count is: 0

Current count is: 0

Current count is: 0

Current count is: 0

Current count is: 0

Current count is: 0


Look carefully at the constructor and destructor for X. The constructor increments the value of count as long as count is less than MAX. The destructor decrements count. Thus, count is incremented when an X object is created and decremented when an X object is destroyed. But no more than MAX objects can exist at any one time. However, in main( ), f( ) is called MAX*2 times without causing an error! Here is why. Inside f( ), an object of type X is created, causing count to be incremented, and then the function returns. This causes the object to immediately go out of scope and its destructor to be called, which decrements count. Thus, calling f( ) has no net effect on the value of count. This means that it can be called indefinitely. However, this is not the case when this program is converted to Java.

Here is the Java version of the preceding program:

// This Java program will fail after 5 calls to f().


class X {

static final int MAX = 5;

static int count = 0;

// constructor

X() {

if(count<MAX) {


count++;

}

else {

System.out.println("Error — can't construct");

System.exit(1);

}

}

// finalization

protected void finalize() {

count—;

}

static void f()

{

X ob = new X(); // allocate an object

// destruct on way out

}

public static void main(String args[]) {


int i;

for(i=0; i < (MAX*2); i++) {

f();

System.out.println("Current count is: " + count);

}

}

}


This program will fail after five calls to f( ), as this

output shows:

Current count is: 1

Current count is: 2

Current count is: 3

Current count is: 4

Current count is: 5

Error — can't construct

The reason the program fails is that garbage collection does not occur each time f( ) returns. Thus, finalize( ) is not invoked, and the value of count is not decremented. After five calls to the method, count reaches its maximum value and the program fails. It is important to emphasize that precisely when garbage collection occurs is implementation dependent. It is possible that for some implementation of Java, on some platform, the preceding program will function similarly to its C++ version. However, the point of the example remains: In C++, you know when and where a destructor will be called. In Java, you do not know when or where finalize( ) will be executed. Therefore, when porting code from C++ to Java, you will need to watch for instances in which the precise timing of the execution of a destructor is relied upon.

Friday, July 29, 2011

Event,Listeners and Adapters in JAVA

Event:-
An event typically signifies an action by the user, such as striking a key or clicking the mouse over a JButton component. But it can also refer to any other action performed by the user or the program. An event can be generated when the value of component's property changes or when a specified amount of time elapses.
Almost all programs must respond to commands from the user in order to be useful. Java's AWT uses event driven programming to achieve processing of user actins: one that underlies all modern window systems programming. Within the AWT, all user actions belong to an abstract set of things called events. An event describes, in sufficient detail, a particular user action. Rather than the program actively collecting user-generated events, the Java run time notifies the program when an interesting event occurs. Programs that handle user interaction in this fashion are said to be event driven.

There are three parts to the event model in Java:

Event object - this is an instance of a Java class that contains the characteristics of the event. For example, if the event is generated from clicking a mouse button, the event object would contain information such as the coordinates of the mouse cursor, which button was clicked, how many times it was clicked, etc.

Dispatching class/method - this is an object, which detects that an event has occurred and is then responsible for notifying other objects of the event, passing the appropriate event object to those objects. These other objects are "listeners" for the event. Most AWT components, such as Button, List, Textfield, etc. are examples of dispatching classes.

A Button, for instance, is capable of notifying other components when it is "pushed." These classes will typically have a set of two methods that can be invoked by would-be "listeners": one to tell the class that the object wants to listen and another to tell the class that the object no longer wants to listen.

These methods are conventionally named i.e. addxxListener (to add an object as a listener) or removexxListener (to remove the object as a listener).In the case of the Button, this would be "Action" to indicate the action of pushing the button. (So the methods would be addActionListener and removeActionListener).

Listener Interface - for the dispatching to work properly, the dispatching class must be able to rely on each of its listeners to contain the method that it executes when the event occurs. This is easily accomplished in Java through the use of an Interface class. The important point is that a class, which is going to be a listener, must implement that interface








Event Objects:-
Different types of events are represented by different Java classes. The base class, from which all events inherit, is java.util.EventObject. AWT defines its own base class for GUI events, java.awt.AWTEvent, which is subclassed from EventObject. AWT then defines a number of subclasses of AWTEvent in the package java.awt.event. Swing uses many of these event types and also defines more of its own in the javax.swing.event package. Some Swing events subclass AWT events, but many subclass java.util.EventObject directly. There is one other kind of event used by Swing components: the java.beans.PropertyChangeEvent, which is part of the JavaBeans component model.



The base EventObject class defines a getSource() method that returns the object that generated or triggered the event. AWTEvent defines the getID() method; the value returned by this method is used to distinguish the various types of events that are represented by the same event class. For example, FocusEvent has two possible types: FocusEvent.FOCUS_GAINED and FocusEvent.FOCUS_LOST.

In addition to these getSource() and getID() methods, the various event subclasses define methods to return whatever data values are pertinent to the particular event type. For example, MouseEvent has getX(), getY(), and getClickCount() methods; it also inherits the getModifiers() and getWhen() methods, among others, from its superclass InputEvent. Thus, when the user clicks the mouse, you receive a MouseEvent that specifies where, when, and how many times the user clicked, along with other information, such as the set of keyboard modifier keys that were held down at the time.

Event Listeners:-
An object that would like to be notified of and respond to an event is an event listener. An object that generates a particular kind of event, called an event source, maintains a list of listeners that are interested in being notified when that kind of event occurs. The event source provides methods that allow listeners to add and remove themselves from this list of interested objects. When the event source generates an event (or when a user input event such as a mouse click or a key press occurs on the event source object), the event source notifies all the listener objects that the event has occurred.

All AWT and Swing components are event sources, and all of them define (or inherit) methods for adding and removing event listeners. By convention, these methods have names that begin with "add" or "remove" and end with "Listener". So, for example, the JButton class inherits the addActionListener() and removeActionListener() methods. In the reference section of this book, you'll notice that the event registration methods of a component are grouped separately, just as the property accessor methods are. This is because one of the most important things you need to know about a component is the list of event types that it can generate.

Each type of event object typically has a corresponding event listener type. The ActionEvent event type has an ActionListener listener type, for example. Event listeners, such as ActionListener, are interfaces that extend java.util.EventListener. EventListener doesn't define any methods; it is merely a marker interface that gives all event listeners a common type. An event listener interface defines one or more methods that an event source may invoke when a particular type of event occurs. Such a method always takes an event object as its single argument. For example, the ActionListener interface defines a single method, actionPerformed(). When the user clicks on a JButton component, an ActionEvent representing that click is created and passed to the actionPerformed() method of each ActionListener object that was registered on the JButton with the addActionListener() method.

An event listener interface may define more than one method. For example, MouseListener defines several methods that correspond to different types of mouse events, including button press events and button release events. This is because MouseEvent represents several different types of mouse events. By convention, each method of an event listener is passed a single argument that is an event object of the type that corresponds to the listener. Thus, a MouseEvent object is always created when a mouse event occurs, but the object is passed to a different listener method depending on the type of mouse event that occurred.

Event Adapters:-
When an event listener interface defines more than one method, it is often accompanied by an event adapter class that provides empty implementations for each of the methods. For example, the MouseListener interface defines five different methods. If your program is interested only in the mouseClicked() method, it may be easier for you to subclass the MouseAdapter class and override mouseClicked() than to implement all five methods of the MouseListener interface directly.

Thursday, July 14, 2011

What is Java applet

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual Machine (JVM). For information and examples on how to include an applet in an HTML page, refer to this description of the <APPLET> tag.



Overview:
Applets are used to provide interactive features to web applications that cannot be provided by HTML alone. They can capture mouse input and also have controls like buttons or check boxes. In response to the user action an applet can change the provided graphic content. This makes applets well suitable for demonstration, visualization and teaching. There are online applet collections for studying various subjects, from physics to heart physiology. Applets are also used to create online game collections that allow players to compete against live opponents in real-time.
An applet can also be a text area only, providing, for instance, a cross platform command-line interface to some remote system. If needed, an applet can leave the dedicated area and run as a separate window. However, applets have very little control over web page content outside the applet dedicated area, so they are less useful for improving the site appearance in general (while applets like news tickers or WYSIWYG editors are also known). Applets can also play media in formats that are not natively supported by the browser
HTML pages may embed parameters that are passed to the applet. Hence the same applet may appear differently depending on the parameters that were passed.
As applets have been available before CSS, they were also widely used for trivial effects like navigation buttons. This use is criticized and declining.

Technical information:
Java applets are executed in a sandbox by most web browsers, preventing them from accessing local data like clipboard or file system. The code of the applet is downloaded from a web server and the browser either embeds the applet into a web page or opens a new window showing the applet's user interface.
A Java applet extends the class java.applet.Applet, or in the case of a Swing applet, javax.swing.JApplet. The class must override methods from the applet class to set up a user interface inside itself (Applet is a descendant of Panel which is a descendant of Container. As applet inherits from container, it has largely the same user interface possibilities as an ordinary Java application, including regions with user specific visualization.
The first implementations involved downloading an applet class by class. While classes are small files, there are frequently a lot of them, so applets got a reputation as slow loading components. However, since jars were introduced, an applet is usually delivered as a single file that has a size of the bigger image (hundreds of kilobytes to several megabytes).
The domain from where the applet executable has been downloaded is the only domain to which the usual (unsigned) applet is allowed to communicate. This domain can be different from the domain where the surrounding HTML document is hosted.
Java system libraries and runtimes are backwards compatible, allowing to write code that runs both on current and on future versions of the Java virtual machine.

Similar technologies:
Many Java developers, blogs and magazines are recommending that the Java Web Start technology be used in place of Applets.
A Java Servlet is sometimes informally compared to be "like" a server-side applet, but it is different in its language, functions, and in each of the characteristics described here about applets.

Embedding into web page:
The applet can be displayed on the web page by making use of the deprecated applet HTML element, or the recommended object element. A non standard embed element can be used with Mozilla family browsers. This specifies the applet's source and location. Object and embed tags can also download and install Java virtual machine (if required) or at least lead to the plugin page. Applet and object tags also support loading of the serialized applets that start in some particular (rather than initial) state. Tags also specify the message that shows up in place of the applet if the browser cannot run it due any reason.
However, despite object being officially a recommended tag, as of 2010, the support of the object tag was not yet consistent among browsers and Sun kept recommending the older applet tag for deploying in multibrowser environments, as it remained the only tag consistently supported by the most popular browsers. To support multiple browsers, the object tag currently requires JavaScript (that recognizes the browser and adjusts the tag), usage of additional browser-specific tags or delivering adapted output from the server side. Deprecating applet tag has been criticised. Oracle now provides a maintained JavaScript code to launch applets with cross platform workarounds.

Advantages:
A Java applet can have any or all of the following advantages:
  • It is simple to make it work on Linux, Microsoft Windows and Mac OS X i.e. to make it cross platform. Applets are supported by most web browsers.
  • The same applet can work on "all" installed versions of Java at the same time, rather than just the latest plug-in version only. However, if an applet requires a later version of the Java Runtime Environment (JRE) the client will be forced to wait during the large download.
  • Most web browsers cache applets, so will be quick to load when returning to a web page. Applets also improve with use: after a first applet is run, the JVM is already running and starts quickly (the JVM will need to restart each time the browser starts afresh).
  • It can move the work from the server to the client, making a web solution more scalable with the number of users/clients.
  • If a standalone program (like Google Earth) talks to a web server, that server normally needs to support all prior versions for users which have not kept their client software updated. In contrast, a properly configured browser loads (and caches) the latest applet version, so there is no need to support legacy versions.
  • The applet naturally supports the changing user state, such as figure positions on the chessboard.
  • Developers can develop and debug an applet direct simply by creating a main routine (either in the applet's class or in a separate class) and calling init() and start() on the applet, thus allowing for development in their favorite Java SE development environment. All one has to do after that is re-test the applet in the AppletViewer program or a web browser to ensure it conforms to security restrictions.
  • An untrusted applet has no access to the local machine and can only access the server it came from. This makes such an applet much safer to run than a standalone executable that it could replace. However, a signed applet can have full access to the machine it is running on if the user agrees.
  • Java applets are fast - and can even have similar performance to native installed software.

Disadvantages:
A Java applet may have any of the following disadvantages:
  • It requires the Java plug-in.
  • Some organizations only allow software installed by the administrators. As a result, some users can only view applets that are important enough to justify contacting the administrator to request installation of the Java plug-in.
  • As with any client-side scripting, security restrictions may make it difficult or even impossible for an untrusted applet to achieve the desired goals.
  • Some applets require a specific JRE. This is discouraged.
  • If an applet requires a newer JRE than available on the system, or a specific JRE, the user running it the first time will need to wait for the large JRE download to complete.
  • Java automatic installation or update may fail if a proxy server is used to access the web. This makes applets with specific requirements impossible to run unless Java is manually updated. The Java automatic updater that is part of a Java installation also may be complex to configure if it must work through a proxy.
  • Unlike the older applet tag, the object tag needs workarounds to write a cross-browser HTML document.






(Courtesy: wikipedia.com)

Thursday, June 9, 2011

How To Block Websites In Ubuntu (Linux)

1) Open the Terminal app found in the Accessories folder in the "Applications" menu.



2) Type

sudo gedit /etc/hosts


in the prompt that appears

3)Terminal ask for your password , and after entering password a text editor will display



4) Add a line under the "127.0.0.1" line that reads "0.0.0.0" followed by the website you want to block.

5) Click the "Save" button, then restart your computer to make the changes take effect.

Tuesday, June 7, 2011

Running a Java Program from Command Prompt

  • Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java with the following text:
    public class HelloWorld
    {
    public static void main(String[] args)
    {
    System.out.println("Hello, World!");
    }
    }
  • Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose "Save as file type:" All files, then type in the file name HelloWorld.java.

  • Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
    C:\> cd \mywork
    This makes C:\mywork the current directory.
    C:\mywork> dir
    This displays the directory contents. You should see HelloWorld.java among the files.
    C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
    This tells the system where to find JDK programs.
    C:\mywork> javac HelloWorld.java
    This runs javac.exe, the compiler. You should see nothing but the next system prompt...
    C:\mywork> dir
    javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
    C:\mywork> java HelloWorld
    This runs the Java interpreter. You should see the program output:
    Hello, World!

    If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java HelloWorld command. Java is case-sensitive!

Saturday, May 28, 2011

Java vs. C++



The differences between the C++ and Java programming languages can be traced to their heritage, as they have different design goals.

C++ :-
C++ was designed for systems and applications programming, extending the C programming language. To this procedural programming language designed for efficient execution, C++ has added support for statically-typed object-oriented programming, exception handling, scoped resource management, and generic programming, in particular. It also added a standard library which includes generic containers and algorithms.

Java :-
Java was created initially as an interpreter for printing systems but grew to support network computing. Sun Microsystems used it for the basis of their "HotJava" thin client system. It relies on a virtual machine to be secure and highly portable. It is bundled with an extensive library designed to provide a complete abstraction of the underlying platform. Java is a statically-typed object-oriented language that uses a syntax similar to C++, but is not compatible with it. It was designed from scratch, with the goal of being easy to use and accessible to a wider audience.

The different goals in the development of C++ and Java resulted in different principles and design trade-offs between the languages. The differences are as follows :

Java versus C++: General programming issues

Java C++
Method bodies must be defined inside the class to
which they belong.
Method bodies must be defined inside the class to
which they belong.
No forward referencing required. Explicit forward referencing required.
No preprocessor. Heavy reliance on preprocessor.
No comma operator. Comma operator.
No variable-length parameter lists. Variable-length parameter lists.
No optional method parameters. Optional function parameters.
No const reference parameters. const reference parameters.
No goto goto
Labels on break and continue. No labels on break and continue.
Command-line arguments do not include the
program name.
Command-line arguments do not include the
program name.
Main method cannot return a value. Main function can return a value.
No global variables. Global variables.
Character escape sequences can appear in a program. Character escape sequences must appear in a string
or character literal.
Cannot mask identifiers through scope. Can mask identifiers through scope.

Java versus C++: Object-oriented programming
Java C++
Pure object-oriented language. Hybrid between procedural and object-oriented.
All functions (methods) are part of a class. Can have stand-along functions.
No multiple inheritance. Multiple inheritance.
Formal interface specifications. No formal interface specifications.
No parameterized type. Templates as parameterized type.
No operator overloading. Operator overloading.
All methods (except final methods) are dynamically
bound.
Virtual functions are dynamically bound.
Java versus C++: Primitive types
Java C++
Two type categories. Various type categories.
All nonprimitive types are objects. Separate types for structs, unions, enums, and arrays.
All numeric types are signed. Signed and unsigned numeric types.
All primitive types are a fixed size for all platforms. Primitive type size varies by platform.
16-bit Unicode characters. 8-bit ASCII characters.
Boolean data type primitive. No explicit boolean data type.
Conditions must be boolean expressions. Integer results are interpreted as boolean conditions.
Variables are automatically initialized. No automatic initialization of variables.

Java versus C++: Pointers and data structures


Java C++
References, with no explicit pointer manipulation
and no pointer arithmetic.
Pointers, with dereferencing (* or ->) and address (&)
operators.
Array references are not translated to pointer arithmetic. Array references translate to pointer arithmetic.
Arrays automatically check index limits. No automatically array bounds checking.
Array lengths in multidimensional arrays can vary
from one element to the next within one dimension.
Array lengths in multidimensional arrays are all the
same size in a give dimension, fixed by the declaration.
Strings are objects. Strings are null-terminated character arrays.
Built-in string concatenation operator(+). String concatenation through a library function.
Use string concatenation operator for long string literals. Use line continuation (\) for long string literals.
No typedef. typedef to define types.
Java versus C++: Special characteristics
Java C++
Specifically attuned to network and Web processing. No relationship to networks or the Web.
Automatic garbage collection. No automatic garbage collection.
Combination of compiled and interpreted. Compiled.
Slower execution when interpreted. Fast execution.
Architecture neutral. Architecture specific.
Supports multithreading. No multithreading.
Automatic generation of documentation in HTML
format.
No automatic documentation generation

Wednesday, May 25, 2011

One of the best interviews!!!

Interviewer: Tell me about yourself.

Candidate: I am SAMEER GUPTA. I did my Tele Communication engineering from

BabanRao Dhole-Patil Institute of Technology.

Interviewer: BabanRao Dhole-Patil Institute of Technology? I had never heard

of this college before!

Candidate: Great! Even I had not heard of it before getting an admission

into it . What happened is - due to cricket world cup I scored badly! in 12th.I

was getting a paid seat in a good college. But my father said (I prefer to

call him 'baap') - "I can not invest so much of money".(The baap actually said

- "I will never waste so much of money on you"). So I had to join this

college. Frankly speaking this name - BabanRao Dhole-Patil, can at the most be

related to a Shetakari Mahavidyalaya.

Interviewer: ok, ok. It seems you have taken 6 years to complete your

engineering.

Candidate: Actually I tried my best to finish it in 4 years. But you

know, these cricket matches and football world cup, and tennis

tournaments. It is difficult to concentrate. So I flunked in 2nd and

3rd year. So in all I took 4 + 2 = 7 years.

Interviewer: But 4+2 is 6.

Candidate: Oh, is it? You know I always had KT in maths. But I will try

to keep this in mind. 4+2 is 6, good, thanks. These cricket matches

really affect exams a lot. I think they should ban it.

Interviewer: Good to know that you want cricket matches to be banned.

Candidate: No, no... I am talking about Exams!!

Interviewer: Ok, What is your biggest achievement in life?

Candidate: Obviously, completing my Engineering. My mom never thought I

would complete it. In fact, when i flunked in 3rd year, she was looking for a job

for me in BEST (Bus corporation in Maharashtra) through some relative.

Interviewer: Do you have any plans of higher study?

Candidate: he he he.. Are you kidding? Completing 'lower' education

itself was so much of pain!!

Interviewer: Let's talk about technical stuff. On which platforms have

you worked? Candidate: Well, I work at SEEPZ, so you can say Andheri is my current

platform. Earlier I was at Vashi center. So Vashi was my platform then. As you can

see I have experience of different platforms! (Vashi and Andheri are the

places in Mumbai)

Interviewer: And which languages have you used?

Candidate: Marathi, Hindi, English. By the way, I can keep quiet in

German, French, Russian and many other languages.

Interviewer: Why VC is better than VB?

Candidate: It is a common sense - C comes after B. So VC is a higher

version than VB. I heard very soon they are coming up with a new

language VD!

Interviewer: Do you know anything about Assembly Language?

Candidate: Well, I have not heard of it. But I guess, this is the

language our ministers and MPs use in assembly.

Interviewer: What is your general project experience?

Candidate: My general experience about projects is - most of the times

they are in pipeline!

Interviewer: Can you tell me about your current job?

Candidate: Sure, Currently I am working for Bata InfoTech ltd. Since

joining BIL, I am on Bench. Before joining BIL, I used to think that

Bench was another software like Windows.

Interviewer: Do you have any project management experience?

Candidate: No, but I guess it shouldn't be difficult. I know Word and

Excel. I can talk a lot. I know how to dial for International phone call

and use speaker facility. And very important - I know few words like -

'Showstoppers ' , 'hotfixes',

'SEI-CMM','quality','versioncontrol','deadlines' , 'Customer

Satisfaction' etc. Also I can blame others for my mistakes!

Interviewer: What are your expectations from our company?

Candidate: Not much.

1. I should at least get 40,000 in hand.

2. I would like to work on a live EJB project. But it should not have

deadlines. I personally feel that pressure affects natural talent.

3. I believe in flexi-timings.

4. Dress code is against basic freedom, so I

would like to wear t-shirt and jeans.

5. We must have sat-sun off. I will suggest Wednesday off also, so as to

avoid breakdown due to overwork.

6. I would like to go abroad 3 times a year on short term

preferably 2-4 months) assignments. Personally I prefer US, Australia and

Europe. But considering the fact that there is a world cup in West Indies in

2007, I don't mind going there in that period. As you can see I am modest and

don't have many expectations. So can I assume my selection?

Interviewer: he he he ha ha ha. Thanks for your interest in our

organization. In fact I was never entertained so much before. Welcome to

INFO-SYS .. :-))

No intention to offend anybody..

Tuesday, May 10, 2011

How to Catch a LION

Newton 's Method:

Let, the lion catch you.

For every action there is an equal and opposite reaction.

Implies you caught lion.

Einstein Method:

Run in the direction opposite to that of the lion.

Due to higher relative velocity, the lion will also run faster and will get tired soon.

Now you can trap it easily.

Indian Police Method:

Catch any animal and interrogate it & torture it to accept that its a lion.

Rajnikanth Method :

Keep warning the lion that u may come and attack anytime.

The lion will live in fear and die soon in fear itself.

Jayalalitha Method:

Send Police commissioner Muthukaruppan around 2AM and kill it, while it's sleeping !

Manirathnam Method (director):

Make sure the lion does not get sun light and put the lion in a dark

room with a single candle lighted.

Keep murmuring something in its ears.

The lion will be highly irritated and commit suicide.

Karan Johar Method (director):

Send a lioness into the forest.

Our lion and lioness fall in love with each other.

Send another lioness in to the forest, followed by another lion.

First lion loves the first lioness and the second lion loves the 2nd lioness.

But 2nd lioness loves both lions.

Now send another lioness (third) into the forest.

You don't understand right... ok....read it after 15 yrs, then also u wont!

Yash Chopra method (director):

Take the lion to Australia or US.. and kill it in a good scenic location.

Govinda method:

Continuously dance before the lion for 5 or 6 days.

Menaka Gandhi method:

Save the lion from a danger and feed him with some vegetables continuously.

George bush method:

Link the lion with Osama bin laden and shoot him!!!

Rahul Dravid s method:

Ask the lion to bowl at u.

U bat for 200 balls and score 1 run

Lion tires and surrenders

And finally ..

Software Engineer Method:

Catch a cat and claim that your testing has proven that its a Lion.

If anyone comes back with issues tell that you will upgrade it to Lion.

Monday, April 25, 2011

Linux vs. Windows



Topic Linux Windows
Price The majority of Linux variants are available for free or at a much lower price than Microsoft Windows. Microsoft Windows can run between $50.00 - $150.00 US dollars per each license copy.
Ease Although the majority Linux variants have improved dramatically in ease of use, Windows is still much easier to use for new computer users. Microsoft has made several advancements and changes that have made it a much easier to use operating system, and although arguably it may not be the easiest operating system, it is still Easier than Linux.
Reliability The majority of Linux variants and versions are notoriously reliable and can often run for months and years without needing to be rebooted. Although Microsoft Windows has made great improvements in reliability over the last few versions of Windows, it still cannot match the reliability of Linux.
Software Linux has a large variety of available software programs, utilities, and games. However, Windows has a much larger selection of available software. Because of the large amount of Microsoft Windows users, there is a much larger selection of available software programs, utilities, and games for Windows.
Software Cost Many of the available software programs, utilities, and games available on Linux are freeware or open source. Even such complex programs such as Gimp, OpenOffice, StarOffice, and wine are available for free or at a low cost. Although Windows does have software programs, utilities, and games for free, the majority of the programs will cost anywhere between $20.00 - $200.00+ US dollars per copy.
Hardware Linux companies and hardware manufacturers have made great advancements in hardware support for Linux and today Linux will support most hardware devices. However, many companies still do not offer drivers or support for their hardware in Linux. Because of the amount of Microsoft Windows users and the broader driver support, Windows has a much larger support for hardware devices and a good majority of hardware manufacturers will support their products in Microsoft Windows.
Security Linux is and has always been a very secure operating system. Although it still can be attacked when compared to Windows, it much more secure. Although Microsoft has made great improvements over the years with security on their operating system, their operating system continues to be the most vulnerable to viruses and other attacks.
Open Source Many of the Linux variants and many Linux programs are open source and enable users to customize or modify the code however they wish to. Microsoft Windows is not open source and the majority of Windows programs are not open source.
Support Although it may be more difficult to find users familiar with all Linux variants, there are vast amounts of available online documentation and help, available books, and support available for Linux. Microsoft Windows includes its own help section, has vast amount of available online documentation and help, as well as books on each of the versions of Windows.


Advantages of Linux:

  1. Cost – The most obvious advantage of using Linux is the fact that it is free to obtain, while Microsoft products are available for a hefty and sometimes recurring fee. Microsoft licenses typically are only allowed to be installed on a single computer, whereas a Linux distribution can be installed on any number of computers, without paying a single dime.
  2. Security – In line with the costs, the security aspect of Linux is much stronger than that of Windows. Why should you have to spend extra money for virus protection software? The Linux operating system has been around since the early nineties and has managed to stay secure in the realm of widespread viruses, spyware and adware for all these years. Sure, the argument of the Linux desktop not being as widely used is a factor as to why there are no viruses. My rebuttle is that the Linux operating system is open source and if there were a widespread Linux virus released today, there would be hundreds of patches released tomorrow, either by ordinary people that use the operating system or by the distribution maintainers. We wouldn’t need to wait for a patch from a single company like we do with Windows.
  3. Choice (Freedom) – The power of choice is a great Linux advantage. With Linux, you have the power to control just about every aspect of the operating system. Two major features you have control of are your desktops look and feel by way of numerous Window Managers, and the kernel. In Windows, your either stuck using the boring default desktop theme, or risking corruption or failure by installing a third-party shell.
  4. Software - There are so many software choices when it comes to doing any specific task. You could search for a text editor on Freshmeat and yield hundreds, if not thousands of results. My article on 5 Linux text editors you should know about explains how there are so many options just for editing text on the command-line due to the open source nature of Linux. Regular users and programmers contribute applications all the time. Sometimes its a simple modification or feature enhancement of a already existing piece of software, sometimes its a brand new application. In addition, software on Linux tends to be packed with more features and greater usability than software on Windows. Best of all, the vast majority of Linux software is free and open source. Not only are you getting the software for no charge, but you have the option to modify the source code and add more features if you understand the programming language. What more could you ask for?
  5. Hardware - Linux is perfect for those old computers with barely any processing power or memory you have sitting in your garage or basement collecting dust. Install Linux and use it as a firewall, a file server, or a backup server. There are endless possibilities. Old 386 or 486 computers with barely any RAM run Linux without any issue. Good luck running Windows on these machines and actually finding a use for them.
Disadvantages of Linux:

  1. Understanding – Becoming familiar with the Linux operating system requires patience as well as a strong learning curve. You must have the desire to read and figure things out on your own, rather than having everything done for you. Check out the 20 must read howto’s and guides for Linux.
  2. Compatibility – Because of its free nature, Linux is sometimes behind the curve when it comes to brand new hardware compatibility. Though the kernel contributors and maintainers work hard at keeping the kernel up to date, Linux does not have as much of a corporate backing as alternative operating systems. Sometimes you can find third party applications, sometimes you can’t.
  3. Alternative Programs – Though Linux developers have done a great job at creating alternatives to popular Windows applications, there are still some applications that exist on Windows that have no equivalent Linux application. Read Alternatives to Windows Applications to find out some of the popular alternatives.

Sunday, April 24, 2011

Universal Laws(Funny)

1. Law of Mechanical Repair - After your hands become coated with grease, your nose will begin to itch and you'll have to pee.

2. Law of Gravity - Any tool, nut, bolt, screw, when dropped, will roll to the least accessible corner.

3. Law of Probability -The probability of being watched is directly proportional to the stupidity of your act

4. Law of Random Numbers - If you dial a wrong number, you never get a busy signal and someone always answers.

5. Law of the Alibi - If you tell the boss you were late for work because you had a flat tire, the very next morning you will have a flat tire.

6. Variation Law - If you change lines (or traffic lanes), the one you were in will always move faster than the one you are in now (works every time).

7. Law of the Bath - When the body is fully immersed in water, the telephone rings.

8. Law of Close Encounters -The probability of meeting someone you know increases dramatically when you are with someone you don't want to be seen with.

9. Law of the Result - When you try to prove to someone that a machine won't work, it will.

10. Law of bio mechanics - The severity of the itch is inversely proportional to the reach.

11.. Law of the Theater and Hockey Arena - At any event, the people whose seats are furthest from the aisle, always arrive last. They are the ones who will leave their seats several times to go for food, beer, or the toilet and who leave early before the end of the performance or the game is over. The folks in the aisle seats come early, never move once, have long gangly legs or big bellies, and stay to the bitter end of the performance. The aisle people also are very surly folk.

12. The Coffee Law - As soon as you sit down to a cup of hot coffee, your boss will ask you to do something which will last until the coffee is cold.

13. Murphy's Law of Lockers - If there are only two people in a locker room, they will have adjacent lockers.

14. Law of Physical Surfaces - The chances of an open-faced jelly sandwich landing face down on a floor, are directly correlated to the newness and cost of the carpet or rug.

15. Law of Logical Argument - Anything is possible if you don't know what you are talking about.

16. Brown's Law of Physical Appearance - If the clothes fit, they're ugly.

17. Oliver's Law of Public Speaking - A closed mouth gathers no feet.

18. Wilson's Law of Commercial Marketing Strategy - As soon as you find a product that you really like, they will stop making it.

19. Doctors' Law - If you don't feel well, make an appointment to go to the doctor, by the time you get there you'll feel better. But don't make an appointment, and you'll stay sick.