Monday, December 01, 2008

Android Applications: 

An application in Android is defined by the contents of its manifest.

Each Android application declares all its activities, entry points, communication layers, permissions, and intents through AndroidManifest.xml. Four basic building blocks, when combined, comprise a rich Android application: 

ƒ Activity: The most basic building block of an Android application.

ƒ Intent receiver: A reactive object launched to handle a specific task.

ƒ Service: A background process with no user interface.

ƒ Content provider: A basic superclass framework for handling and storing data.

Thursday, October 23, 2008

Installing the Android Eclipse Plug-In :

I like graphical user interfaces (GUIs), provided they have hotkeys like the 

Eclipse IDE, when working with Android. To get more than basic 
functionally out of the process, you’ll need to download the Android 
Developer Tools. To install it from within Eclipse, follow the directions outlined by Google.

http://code.google.com/android/intro/installing.html#installingplugin

If you’ve already installed the older version of the SDK and the Eclipse 

plug-in, I recommend you go back and update it to M5-RC15 (or the latest 
version) now using the previously mentioned links. Enough has changed 
between the older version and the latest that the changing details could be 
confusing. If you correctly follow the directions but get an error when 
trying to install the Android editors, go back and install the full version of 
Java EE Eclipse. The basic Java SDK doesn’t include all the correct packages used by the Android plug-in. 

Don’t forget to point the Android plug-in to where you unpacked your copy of the SDK. It’ll be in Windows/Preferences/Android on the Android tab. 

Create a new project by selecting File h New h Android Project. Give the 
project and activity a pithy name of your choosing. You’ll also have to 
insert into your source package name at least one dot (.), such as apress. 
book.sample or crazy.flyingmonkey.application. 

New Session Android JAVA : 

Getting the Android SDK :

You can find the Android SDK on Google’s website at 

http://code.google.com/android/download.html

Grab it, download it somewhere handy, and then unpack it.

I’ve put mine in my Development folder at /Developer/AndroidSDK. 

You can just as easily put the ZIP file anywhere on your filesystem.

Just remember where you’ve stashed it, because you’ll need to tell Eclipse where it is later.

It’s also a good idea, if you’re a Windows or Linux user, 

to add the location of the Android tools to your Path variable. 


Tuesday, September 30, 2008

An Overview of RMI Applications :

RMI applications often comprise two separate programs, a server and a client. A typical server program creates some remote objects, makes references to these objects accessible, and waits for clients to invoke methods on these objects. A typical client program obtains a remote reference to one or more remote objects on a server and then invokes methods on them. RMI provides the mechanism by which the server and the client communicate and pass information back and forth. Such an application is sometimes referred to as a distributed object application. 


Distributed object applications need to do the following: 

Locate remote objects. Applications can use various mechanisms to obtain references to remote objects. For example, an application can register its remote objects with RMI's simple naming facility, the RMI registry. Alternatively, an application can pass and return remote object references as part of other remote invocations. 
Communicate with remote objects. Details of communication between remote objects are handled by RMI. To the programmer, remote communication looks similar to regular Java method invocations. 
Load class definitions for objects that are passed around. Because RMI enables objects to be passed back and forth, it provides mechanisms for loading an object's class definitions as well as for transmitting an object's data.

Sunday, August 31, 2008

Hibernate Types  in JAVA:

Hibernate types fall into three broad categories: entities, components, and values.

1.) Entities:

Generally, an entity is a POJO class that has been mapped into the database using the or elements. An entity can also be a dynamic map (actually a Map of Maps). These are mapped against the database in the same way as a POJO, but with the default entity mode of the SessionFactory set to dynamic-map.

2.) Components:

Lying somewhere between entities and values are component types. When the class representation is simple and its instances have a strong one-to-one relationship with instances of another class, then it is a good candidate to become a component of that other class.

3.) Values:

Everything that is not an entity or a component is a value. Generally, these correspond to the data types supported by your database, the collection types, and, optionally, some userdefined types.

Tuesday, July 29, 2008

Preventing Thread Execution : 

A thread that's been stopped usually means a thread that's moved to the dead state.

Its your ability to recognize when a thread will get kicked out of running but not be sent back to either runnable or dead.

For the purpose of the understanding, we aren't concerned with a thread blocking on I/O(say, waiting for something to arrive from an input stream from the server).

We are concerned with the following :

1.)  Sleeping.

2.)  Waiting.

3.)  Blocked because it needs an object's lock.

Thread States in JAVA : 

A thread can be only in one of five states :

New :--> This is the state the thread is in after the Thread instance has been created, but the start() method has not been invoked on the thread. It is a live Thread object, but not yet a thread of execution. At this point, the thread is considered not alive.


Runnable :--> This is the state a thread is in when it's eligible to run, but the scheduler has not selected it to be the running thread. A thread first enters the runnable state when the start() method is invoked, but a thread can also return to the runnable state after either running or coming back from a blocked, waiting, or sleeping state. When the thread is in the runnable state, it is considered alive.

Running :--> This is it. The "big time." Where the action is. This is the state a thread is in when the thread scheduler selects it (from the runnable pool) to be the currently executing process. A thread can transition out of a running state for several reasons, including because "the thread scheduler felt like it." We'll look at those other reasons shortly. Note that in Figure 9-2, there are several ways to get to the runnable state, but only one way to get to the running state: the scheduler chooses a thread from the runnable pool.

Waiting/blocked/sleeping :--> This is the state a thread is in when it's eligible to run. Okay, so this is really three states combined into one, but they all have one thing in common: the thread is still alive, but is currently not eligible to run. In other words, it is not runnable, but it might return to a runnable state later if a particular event occurs. A thread may be blocked waiting for a resource (like I/O or an object's lock), in which case the event that sends it back to runnable is the availability of the resource—for example, if data comes in through the input stream the thread code is reading from, or if the object's lock suddenly becomes available. A thread may be sleeping because the thread's run code tells it to sleep for some period of time, in which case the event that sends it back to runnable is that it wakes up because its sleep time has expired. Or the thread may be waiting, because the thread's run code causes it to wait, in which case the event that sends it back to runnable is that another thread sends a notification that it may no longer be necessary for the thread to wait. The important point is that one thread does not tell another thread to block. Some methods may look like they tell another thread to block, but they don't.

If you have a reference t to another thread, you can write something like this:

t.sleep(); or t.yield()

But those are actually static methods of the Thread class—they don't affect the instance t; instead they are defined to always affect the thread that's currently executing. (This is a good example of why it's a bad idea to use an instance variable to access a static method—it's misleading. There is a method, suspend(), in the Thread class, that lets one thread tell another to suspend, but the suspend() method has been, deprecated and won't be on the exam (nor will its counterpart resume()). There is also a stop () method, but it too has been deprecated and we won't even go there. Both suspend () and stop() turned out to be very dangerous, so you shouldn't use them and again, because they're deprecated, they won't appear on the exam. Don't study 'em, don't use 'em. Note also that a thread in a blocked state is still considered to be alive. 

Dead :--> A thread is considered dead when its run() method completes. It may still be a viable Thread object, but it is no longer a separate thread of execution. Once a thread is dead, it can never be brought back to life! (The whole "I see dead threads" thing.) If you invoke start() on a dead Thread instance, you'll get a runtime (not compiler) exception. And it probably doesn't take a rocket scientist to tell you that if a thread is dead, it is no longer considered to be alive.

Friday, June 27, 2008

Running an Application from the Java Cache Viewer :

If you are using Java Version 1.6.0, you can run a Java Web Start application through the Java Cache Viewer. 

When Java Web Start first loads an application, information from the application's JNLP file is stored in the local Java Cache Viewer. To launch the application again, you do not need to return to the Web page where you first launched it; you can simply open the Java Cache Viewer. 

To open the Java Cache Viewer: 
Open the Control Panel.
Double click on the Java icon. The Java Control Panel opens.
Select the General tab.
Click View. The Java Cache Viewer opens.

Running a Java Web Start Application from a Browser :

You run an application with Java Web Start from a browser simply by clicking a link to the application's JNLP file, such as: 

Launch Notepad Application

Java Web Start then loads and runs the application based on instructions in the JNLP file.


Java Web Start: 

Java Web Start provides the power to launch full-featured applications with a single click. Users can download and launch applications, such as a complete spreadsheet program or an Internet chat client, without going through complicated installation procedures. 


With Java Web Start, the user can launch a Java application by clicking a link in a Web page. The link points to a JNLP file, which instructs Java Web Start to download, cache and run the application. 

Java Web Start provides Java developers and users with many deployment advantages: 
With Java Web Start, you can place a single Java application on a Web server for deployment to a wide variety of platforms, including Windows 2003/Vista/2000/XP, Linux, and SolarisTM 

Java Web Start supports multiple, simultaneous versions of the Java Standard Edition platform.

Specific applications can request specific Java versions without conflicting with the different needs of other applications. Java Web Start automatically downloads and installs the correct version of the Java platform as necessary based on the application's needs and the user's environment. 

Users can launch a Java Web Start application independently of a Web browser. The user can be off-line, or unable to access the browser. Desktop shortcuts can also launch the application, providing the user with the same experience as a native application. 

Java Web Start takes advantage of the inherent security of the Java platform. By default, applications have restricted access to local disk and network resources. Users can safely run applications from sources that are not trusted. 

Applications launched with Java Web Start are cached locally, for improved performance. 

Java Web Start provides limited support for applets through its built-in applet viewer. However, this is not intended to be a full- scale applet environment, such as the one provided by Java Plug-in. Java Web Start's applet viewer has certain limitations; for example, you cannot specify class files as resources, and it does not accept policy files. 

In Java Version 1.4.2 and beyond, Java Web Start is installed as part of the JRE. Users do not have to install it separately or perform additional tasks to use Java Web Start applications. 

Tuesday, May 06, 2008


Method Overloading in JAVA :


When two methods have same name , but have different types or numbers of arguments, the method is overloaded.



Wednesday, April 30, 2008

Creating and Using Arrays in JAVA :

When a number of data items are chunked together into a unit, the result is a data (online) structure. Data structures can be very complex, but in many applications, the appropriate data structure consists simply of a sequence of data items. Data structures of this simple variety can be either arrays or records.

The term “record” is not used in Java. A record is essentially the same as a Java object that has instance variables only, but no instance methods. Some other languages, which do not support objects in general, nevertheless do support records. The C programming language, for example, is not object-oriented, but it has records, which in C go by the name “struct.”

The
data items in a record—in Java, an object’s instance variables—are called the fields of the record. Each item is referred to using a field name. In Java, field names are just the names of the instance variables.

The distinguishing characteristics of a record are that the data items
in the record are referred to by name and that different fields in a record are allowed to be of different types.

Tuesday, April 01, 2008

Swing GUI Components :
The Swing toolkit includes a rich array of components: from basic components, such as buttons and check boxes, to rich and complex components, such as tables and text. Even deceptively simple components, such as text fields, offer sophisticated functionality, such as formatted text input or password field behavior. There are file browsers and dialogs to suit most needs, and if not, customization is possible. If none of Swing's provided components are exactly what you need, you can leverage the basic Swing component functionality to create your own.

Friday, February 29, 2008

Java SE API :

The Java SE application programming interface (API) defines the manner by which an applet or application can make requests to and use the functionality available in the compiled Java SE class libraries. (The Java SE class libraries are also part of the Java SE platform.)

The Java SE API consists of core technologies, Desktop (or client) technologies, and other technologies.

  • Core components provide essential functionality for writing powerful enterprise-worthy programs in key areas such as database access, security, remote method invocation (RMI), and communications.
  • Desktop components add a full range of features to help build applications that provide a rich user experience – deployment products such as Java Plug-in, component modeling APIs such as JavaBeans, and a graphical user interface.
  • Other components round out the functionality.

Tuesday, January 29, 2008

JFC and Swing :

JFC is short for Java Foundation Classes, which encompass a group of features for building graphical user interfaces (GUIs) and adding rich graphics functionality and interactivity to Java applications.

Swing is a
widget toolkit for Java. It is part of Sun Microsystems' Java Foundation Classes (JFC) — an API for providing a graphical user interface (GUI) for Java programs. Swing includes GUI widgets such as text boxes, buttons, split-panes, and tables.

Swing widgets provide more sophisticated GUI
components than the earlier Abstract Window Toolkit. They are designed to be consistent across all platforms, unlike AWT widgets, which map directly to the current platform's graphics interface without modification. Swing supports a pluggable look and feel by using the current platform's graphics interface to achieve consistency through modifications made by additional API calls. This means the application can use any supported look and feel on any platform. The disadvantage of lightweight components is slower execution. The advantage is uniform behavior on all platforms.