Sunday, September 28, 2008

Java For Stand-Alone Application

Java For Stand-Alone Applications

Java programming language was primarily developed to deal with embedded applications. But with the introduction of Swing and other user interface utilities to Java, it made its mark in desktop applications too. Now the trend is to use Java technology in developing large web and enterprise applications. Java is more focused on web then desktop applications. 
But, in this article, we are going to discuss how useful Java is as a development technology for stand alone desktop application development in present scenario.


Java is Suitable for Desktop Applications

There are several applications built on Java technology. Development tools like Eclipse is one the popular example among them. From enterprise applications, Lotus Notes is another good example of desktop Java applications. Such examples show that Java can be used extensively to develop desktop applications apart from installation run times and splash screens. Let us first examine what Java can offer and what are the benefits of using Java as development technology for stand alone applications.

Independence of Java

The most hyped and important feature of Java technology is that it can be used on any platform and on any operating system. Java Virtual Machines are developed for almost all types of hardware and operating system including high-end servers to small palmtop computers and mobile phones. A program written in Java programming language can be executed anywhere provided the Java runtime is available to understand the Byte Code of Java. This feature adds a great value to Java as a development technology for desktop applications. A developer can use the Eclipse application on different operating systems including Window, Linux and Mac Os. This means that desktop applications developed using Java can be used on multiple platforms and multiple operating systems without or with minor changes to it. This saves great amount of development time. Moreover, developers of the application need not worry about operating system implementation of user interface or file management or any such operating system specific feature. Such things are taken care by Java transparently. Some people have wrong concept that developing Java applications is very complex, but features of Java technology actually make development process easier and faster.

Security

From the beginning, Java is known as secure development technology. For stand alone applications, security features are more important. There are applications developed in programming languages that are native to operating system and are found shipping viruses. In this area Java is much secured and reliable technology. Java virtual machine itself intercepts all calls made to operating system from the application – weather it is to establish network connection or to print a file or to access a file from file system of operating system. Moreover Java applies restrictions on access of operating system resources and enables developers to make sure that the applications is not going to harm operating system or any system resource any way.

Manageability

Java is almost pure object oriented programming language (why I am using here the word "almost " because there is a debate going on if Java is purely object oriented or not but that is out of scope for this context). So being an object oriented programming language it is easier to manage than process oriented native languages. Features of Java language like reusability, polymorphism, plug-ability, declarative-ness, configurability makes it most maintainable language.

Pluggable User Interface

There was a time when Java language was much criticized for it’s being poor in look and feel area. But, with the introduction of lightweight Swing components in Java and emergence of reusable JavaBeans, has made Java bounce back in market for developing competitive user interface. Most advantageous feature of Swing technology is that look and feel of the entire application can be changed at fly (at runtime programmatically). This feature is often used to give user freedom to choose from pluggable look and feels (currently three choices are available).

Open Source

Being an open source technology, Java is free to use even for commercial purpose. This way, in order to develop application over the top of Java technology one does not needs to spend money after licensing (unlike native languages). This feature is important in developing desktop applications within a limited budget. Similar features which can be achieved with native languages can also be achieved using Java technology along with developing the application economically.

Remote Access

Reusability of Java objects is one of the well-known features that Java offers. Additional to reusability, Java also offers remote access to object by Remote Method Invocation and CORBA. Using RMI, the developer can access Java objects that are residing on remote host(s). This architecture makes it possible to reuse objects implementing core business logic of the application. RMI also is extensively used to develop LAN applications.

CORBA is a language independent technology that is widely supported and used in Java technology. Using CORBA, developers can access Java objects from other language programs like Cobol, C, C++ and vice versa.

Networking Features

One may be surprised to see this topic here when we are discussing about stand alone applications. But it happens sometimes that stand-alone desktop applications need to access data from network host or internet. In such a case Java has network utilities which facilitates to establish connections to such hosts and access data in a standardized and secured manner. Here we have to remember that before establishing network connection Java checks for security first.

But Beware

There are some points and areas where one has take extra care while developing stand-alone desktop applications using Java technology. As per the above discussion we have understood that Java can be suitably used for desktop application development. But no one is perfect in this world and Java is not an exception here. Let us discuss areas where developers have to take care.

Performance

Here we have to understand that applications developed with Java technology have one more layer to pass to execute any call then those with native languages. The reason is, Java Virtual Machine first interprets Byte Code (compiled Java code) and converts it into instructions which can be executed by operating system. But in case of native languages, they do not need such intermediate interpreter. For this reason, applications developed with native languages can deliver better performance then those with Java. 
Modern Java compilers use batches to interpret Byte Code and also other methods are used to improve performance of JVMs. Using such JVM helps developers to achieve very good performance in Java applications also. Moreover, modern processors and other hardware are so efficient that they can easily cope with such performance overhead. Also there are some best practices used worlds wide in Java applications aimed to fine tune performance of Java applications. Usage of such practices and conventions may help in improving performance of Java desktop applications. 
And also the way Java makes application easy to maintain and scale after development of application adds a lot of flexibility to the application. This advantage can easily take over the performance disadvantage of Java applications.


Complexity of Development

Another area where extra care is required is the complexity of Java language itself. Experience says that native languages are simpler and easy to implement because operating system comes with in-built support to such languages. But in order to develop applications using Java technology, one has to have good knowledge of object oriented programming and language itself. Also, sometimes complexity of development means more development time, which in turn means increased costs. One has to keep in mind that selection of Java as a programming language is due to its cost effectiveness. It should not add cost to project indirectly by taking a lot of time to develop the application.

The first requirement to develop desktop applications with Java technology is that the application should be well designed. The architecture of the application, layers of control, flow of control, usage of advanced features of Java technology etc should be decided in advance of development to take full advantage of the technology. Complexity of the language can be easily overcome by proper design and architecture of the application. These limitations does not mean that Java is not suitable technology for developing stand-alone desktop applications, Complexity of the development should be avoided by following best practices and proper design.

Summary

From the above discussion we can safely summarize that Java is suitable technology to develop stand-alone desktop applications for different operating systems. Even in areas like maintainability, scalability, security and networking, it is far ahead of native programming languages. Also modern hardware and new Java run times are ready to cope with performance drawback of Java language which makes it one of the most suitable desktop programming languages.

Difference Between Java And .Net

Introduction

With the introduction of .NET technology Microsoft was focused to enjoy monopoly in market of development of enterprise applications. But later on J2EE even though being an open source technology fought back and made sure that most of enterprise applications are developed over the top of J2EE framework. In this article we are not going to take side of any of these two prominent and proven technologies. But we are going to discuss areas and scope of both technologies along with their suitability for enterprise applications.

.NET (Go Home Early)

.NET has proved that enterprise applications can be developed with an easy without bothering much about complex architectures and designs. It makes the job of developers easy and also it makes it possible to develop enterprise applications faster.

Integrated

.NET comes with integrated development tool, which makes possible to develop applications really fast. Developer can do many things like web designing, server side programming, configuration etc to the application using the integrated development tool.

Also .NET is integrated with all components along. It comes with VB.NET and C# programming language run time environments so that developer does not need to find, download, install and configure any thing extra to start coding at server side. Similarly for persistence layer, ADO.net is integrated within the .NET framework itself. So the developer can directly start interacting with database from middle layer or business logic layer without worrying size of connection pool it maintains.

.NET framework comes with server-side components integrated within the .NET pack itself like plug-in for Crystal Reports, Web Calendar, Web time picker, popup windows etc. Not only this, but even IIS which is the only standard application server for .NET comes along with the .NET installation kit. Once the developer installs .NET on his Windows operating system he is set to develop entire web application without need of any third party plug-in or APIs. Integrated development environment of .NET technology is one of its advantage which helps developers to develop applications fast.

Easy to Code

Programming with languages like VB.NET is very easy and simple because the language itself is very human friendly. Also the development tools for .NET programming languages are very powerful and user friendly. They support many features like auto completion, auto correction, compile on fly, running applications from IDE, debugging facilities etc. Programming with such tools makes easy and possible to develop applications fast. With such tools programmers can concentrate more on functional and performance aspects of the application.

How About Linux and Solaris???

The major disadvantage of .NET technology comes when we think about independence of deploying and running application on operating systems other then windows. Even though .NET is claimed to be platform independent technology for now we cannot deploy and run .NET applications on other operating systems then Windows. People who have developed .NET claims that once run time environment for .NET is available on Linux and other platforms it can run over them. But still the world is waiting for such run time environment and no commitments are made when they will come to us.

Suitability

Now lets analyze how far .NET is suitable development technology to develop enterprise applications. As we have discussed above, .NET is having major disadvantage of its dependency over the Windows operating system. Other disadvantages can be counted like less scalability, less customizable etc.

Sometimes especially while developing small enterprise applications most important factor considered for development is time taken for it. In such cases, choosing .NET as development technology makes sense because even though it is costly, it can be economic in the sense that it takes less time to develop applications.

We can safely conclude that for small and relatively simple enterprise applications .NET is suitable choice as a development technology.

J2EE (Scale The World)

Some people may find it difficult and complicated to develop enterprise applications over the top of J2EE but it is a fact that most of enterprise applications are being developed with J2EE. The reason why people go for J2EE despite of its complexities is that it comes with considerable advantages which are very crucial for enterprise applications.

Independence

It is a known fact that the application developed with J2EE can be deployed and run from most operating systems without or with minor changes. This makes J2EE technology of choice for enterprise application developers. Because of its platform independence, developer who is programming and unit testing on Windows operating system need not worry if his segment of program is going to work on Linux or not.

Applications developed with J2EE can be deployed on most available hardware. It offers flexibility of hardware to the end user also. Application can be deployed over an existing hardware without any extra cost. So applications developed with J2EE allows end users to deploy and run applications on operating system and hardware of their choice.

Open Source

Java (on which J2EE is based) is an open source technology. It is developed and maintained by the Java community, which is controlled by Sun. And Sun has made Java available without any cost. Even development kit for J2EE is also available for free from Sun and some other vendors. So for people for whom cost is important factor while developing enterprise application, J2EE is the ultimate choice.

Moreover, Java plug-ins and tools are also available for free. E.g. Eclipse development tool, which provides almost all functionalities similar to .NET, IDE is available for free from IBM. So selection of J2EE as development technology can help to reduce const of such tools and plug-ins also.

Think Big

There are some factors those are very important for large, complex enterprise systems and those should be considered while selecting appropriate development technology. Java offers almost all of them. Let us have glance at them in brief.

Scalability: Java applications are scalable because of its component-oriented architecture. It comes with components like Swing components, JavaBeans, Ejb etc. Because of such components, J2EE offers great level of reusability of code and functionalities. Also because of its component driven approach, it offers better control over common functionalities like authentication.

Maintainability: J2EE applications are easier to maintain because in most cases they are designed in multiple layers. So it becomes easy to place a bug and remove it during maintenance stage. Also it is easy to add new functionality or plug-in third party functionalities to J2EE applications because of its scalability feature.

Customization: Applications developed over the top of J2EE offers great level of flexibility. Developers can change implementation and behavior of Java language itself if it is necessary at any stage of development process.

Suitability

Let us examine suitability of J2EE as development technology for enterprise applications. Considering above-mentioned points we can say that to develop large enterprise applications where there is a need of scaling application, reusing its functionalities, higher level of security, higher level of flexibility and great amount of maintainability J2EE should be technology of choice. For small applications where functionality is very simple and easy to maintain J2EE will prove to be very complex technology. The cost factor too plays a vital role here. If there is a requirement that the application will have to be deployed and run on platform other then Windows then it becomes necessary to develop the application with J2EE. One may go for J2EE simply because it is available for free. It is necessary to remember that to develop applications with J2EE is going to take more time then that with .NET. Ultimately one may require more human hours to develop the application, which can result in increased cost again.

Summary

Let us try to summarize cases where both technologies are suitable.NET:

  • If there is need to develop the application within a short period of time.
  • If the end user is ready or willing to bear the cost of .NET, Microsoft operating system and server licensing.
  • If human hours cost more then licensing cost.
  • If there is no need to reuse and scale functionality of application.

J2EE:

  • If the system is having very complicated requirement and has very large scope of functionality.
  • If there are requirement to reuse and scale system functionalities.
  • If there are fewer constraints over time taken for development of application.
  • If the end user if not willing to bear cost of licensing .NET and other related products.
  • If there is requirement to deploy and run the application other then Windows platform.

Java Overview

Java Overview

Java is a programming language that is object oriented. It was created in the 1990s by James Gosling, who worked with Sun Microsystems. While most programming languages are designed to be compiled in to basic code, Java is designed to be compiled to bytecode.

This bytecode can then be processed by the Java Virtual Machine. A lot of the code that Java uses is taken from programming languages such as C++. However, Java uses an approach which is much more simple than C++ or C. 


The creators of Java have five important philosophical goals for the language. Java is a language which should be easy to use, and it should also be able to borrow important elements from older programming languages. It should always use an object oriented approach. Any programs which are created in Java should be able to run on multiple operating systems, and should never be limited to a single OS. It should also be designed to work with computer networks, and it should also be able to remotely initiate code. These are the five goals of Java. 

As of this writing, seven versions of Java have been released or are in development. The latest is Java SE 7, which is also known as dolphin. It is set to be released in 2008. To understand Java, it is first important to understand object oriented programming. This is a method of programming and design which allows the various forms of data which have similar operations to be combined together. For example, data and code will be combined in what is called an "object." An object is a type of package which contains the state and behavior. The behavior is the code, and the state is the data. The goal of object oriented programs like Java is to separate things which alternate from things that remain static. It has been shown that this method of programming makes a language more stable, and it is also easier to work with. 

The ability for applications written in Java to run on multiple platforms is extremely important. The creators of Java felt that an application should be able to run on multiple pieces of hardware once it is created. The Java compiler is responsible for this feature. It will compile the Java code into bytecode. Bytecode is basic machine instructions which can be used on the virtual machine. The virtual machine is a program written in relative code for hardware which will study and use the Java bytecode. A library will often be used to give entrance to elements of the host device. These elements could include networking or graphics. The JIT compiler is responsible for transforming the Java bytecode into a code which is understood by the device. 

Another feature that Java has is called the automatic garbage collection system. With older languages such as C++, programmers are required to manually deal with memory. If the programmer fails to deal with memory, the program may consume too much memory. This is called a memory leak, and can cause the program to crash. Java solves this problem by using the garbage collector. The Java runtime will manage the lifespan of objects. If there are no references to a specific object, the garbage collector will delete it. It will do this in order to make room for memory and avoid memory leaks. This feature makes the design and deletion of objects easier than C++. 

While the syntax used with Java is based on C++, there are a number of differences. Java is a true object oriented programming language. Virtually everything within the Java system will be an object, and it will all be written within a class. All programs created in Java will be written within a class, even programs thate are designed to be standalone applications.


The file name for programs written in Java will always use the .java suffix. The compiler will also create a class file for every class that is registered in the source file. Java is a very impressive program which has a large number of useful applications. However, it has become the target of crticism since it was created. 

Java is not a language which works for all programmers. Many considered the earlier versions of the language to be a lot slower and memory intensive than C++. However, this has changed considerably with newer versions of the language.

Tuesday, September 9, 2008

Google Search Founders

Profile: The Google founders
By Will Smale 


Larry Page (left) and Sergey Brin, Google founders
Larry and Sergey - the boys next door made very good.
The founders of the Google internet search engine - Larry Page and Sergey Brin - are the type of young men most parents would dream of their daughters bringing home.

And far from simply because they will both be billionaires following a stock market flotation of Google.

Instead, most mums and dads would also be drawn to the facts that both men are very clean cut in appearance, undeniably hard working and intelligent, and seem, well, just "nice".

They are your text book, well presented, quietly well behaved "boys next door" from a smart middle class American suburb.

Only a lot richer.

Google staff play roller hockey
A hard day at the office for Google's staff
Yet far from living an extravagant lifestyle, complete with yachts and private jets like fellow software leader Oracle boss Larry Ellison, Mr Page, 31, and Mr Brin, 30, are both reported to continue to live modest, unassuming lifestyles.

They don't even have sports cars, and instead are said to each drive a Toyota Prius, a plain-looking but rather environmentally friendly saloon that is half electric-powered, and growing in popularity among green-minded Americans.

Mr Brin's father even claimed recently that his son still rents a modest two bedroom apartment.

Garage industry

Mr Page and Mr Brin just happen to be geniuses with computers and, by extension, the founders of the world's most popular internet search engine.

Google logo
Google is the undisputed world number one internet search engine

Today both barely in their thirties, the two first met at Stanford University in the mid-1990s, where they were doing doctorates in computer sciences.

Apparently, they did not immediately hit it off, but they became friends while developing a new system of internet search engine from their college dormitory.

Initially called BackRub, they created a software system whereby the search engine would list results according to the popularity of the pages, after realising that more times than not the most popular result would also be the most useful.

So after changing its name to Google they dropped out of college (although Mr Brin is officially still on leave) and the rest, as they say, is history.

Pulling together $1m from family, friends and other investors, on 7 September 1998 Google was commercially launched from a friend's garage.

Growth was quick.

Initially, Google got 10,000 queries per day compared with 200 million today.

Family influences

Both Mr Page and Mr Brin come from an academic and computer science or mathematical background.

Toyota Prius. Pic from Toyota website
The Google founders both drive a Toyota Prius - a very "green" car

Larry - or Lawrence - Page was born and raised in Michigan, the son of Carl Page, a pioneer in computer science and artificial intelligence.

Page Senior earned a doctoral degree in computer science in 1965, back when the subject was still in its infancy, and went on to become a computer science professor at Michigan State University.

His wife, and Larry Page's mother, also worked in computers, teaching computer programming.

Perhaps unsurprisingly, Larry Page says he fell in love with computers at the tender age of six.

Mr Brin is a Muscovite by birth, the son of a Soviet mathematician economist.

His family, who are Jewish, emigrated to the US in 1979 to escape persecution, and Mr Brin went on to get a degree in mathematics and computer science from the University of Maryland, before enrolling at Stanford University as a postgraduate.

Hippy mantra

Google today has its headquarters at Mountain View in the heart of California's famous Silicon Valley, where certain quirks are in place to keep staff happy.

The Google piano
A member of the Google team plays a tune

These include weekly games of roller-hockey in the car park, an on-site masseuse and a piano.

And each member of the team is given one day a week to spend on their own pet projects.

In a nod to the county's former hippy past, the company's head chef is said to have formerly worked for the rock band Grateful Dead.

There is also something very 1960s California about what Mr Page and Mr Brin say is their philosophy.

As Mr Page recently explained to ABC News: "We have a mantra: 'Don't be evil', which is to do the best things we know how for our users, for our customers, for everyone.

"So I think if we were known for that, it would be a wonderful thing."

Nice boys, you see. Wealthy yes, and maybe a little quirky too, but still very nice.


Operations In LHC

LHC operations
Having to accelerate two particles beams at the same time, the LHC is in fact "two machines in one". It will consist of two " superconducting magnetic channels" or "rings" housed in the same yoke and cryostat, a unique configuration that not only saves space but also gives a 25 % cost saving over separate rings!

The two rings will be filled with protons delivered from the SPS and its pre-accelerators at 0.45 TeV, and will accelerate them up to almost the speed of light, at an energy of 7 TeV.

What we call a "proton beam" is in fact a succession of squeezed groups of protons called "bunches". The two LHC beams will consist each of 2835 bunches of 1011 particles each.

Once the 7 TeV energy is reached, the beams will counter-rotate for several hours, and during this time the particles will make four hundred million revolutions around the machine, a truly astronomical number.

At each turn, the beams will be forced to collide in determined places, where the experiments are located.

After about 10 hours the beams will become so degraded that the machine will have to be emptied and refilled.

Why LHC

Why do we need the LHC?
Because our current understanding of the Universe is incomplete.

The theories and discoveries of thousands of physicists over the past century have created a remarkable picture of the fundamental structure of matter, which is called the Standard Model of Particles and Forces. The Standard Model is by now a well-tested physics theory, used to explain and exactly predict a vast variety of phenomena. High-precision experiments have repeatedly verified subtle predicted effects. Nevertheless, physicists know that it can't be the end of the story, as it leaves many unsolved questions.

Among them, the reason why elementary particles have mass, and why their are different, is the most perplexing one. It is remarkable that such a familiar concept is so poorly understood! The answer may lie within the Standard Model, in an idea called the Higgs mechanism. According to this, the whole of space is filled with a 'Higgs field', and by interacting with this field, particles acquire their masses. Particles which interact strongly with the Higgs field are heavy, whilst those which interact weakly are light. The Higgs field has at least one new particle associated with it, the Higgs boson. If such particle exists, the LHC will be able to make it detectable.

Another puzzle concerns the existence of four different forces. When the Universe was young and much hotter than today, perhaps these forces all behaved as one. Particle physicists hope to find a single theoretical framework to prove this, and have already had some success. Two forces, the electromagnetic force and the weak force were 'unified' into a single theory in the 1970s. This theory was experimentally verified in a Nobel prize winning experiment at CERN a few years later. The weakest and the strongest forces, however, gravity and the strong force, remain apart. A very popular idea suggested by the unification of the forces is called supersymmetry or SUSY for short. SUSY predicts that for each known particle there is a 'supersymmetric' partner. If SUSY is right, then supersymmetric particles should be found at the LHC.

Antimatter poses another riddle the LHC will help us also to solve the riddle of antimatter. It was once thought that antimatter was a perfect 'reflection' of matter - that if you replaced matter with antimatter and looked at the result in a mirror, you would not be able to tell the difference. We now know that the reflection is imperfect, and this could have led to the matter-antimatter imbalance. The LHC will be a very good 'antimatter-mirror', allowing us to put the Standard Model through one of its most grueling tests yet.

These are just a few of the questions the LHC should answer, but history has shown that the greatest advances in science are often unexpected. Although we have a good idea of what we hope to find at the LHC, nature may well have surprises in store.

One thing is certain, the LHC will change our view of the Universe.

What Is LHC

A unique tool
The Large Hadron Collider (LHC) is a particle accelerator which is being built at CERN, the European Organization for Nuclear Research, the world's largest particle physics laboratory. When it will switch on in 2008, it will be the most powerful instrument ever built to investigate on particles proprieties.

The LHC will take the place of CERN's Large Electron Positron (LEP) collider, and will sit in its 27 Km long tunnel, about 100m underground. It will accelerate 2 separate beams of protons up to an energy of 7 TeV , and then bring them into head-on collisions (from here the name "collider"). The protons collision energy will then be of 14 TeV. But the LHC will not be limited to the study of proton-proton collisions as it can also collide heavy ions, such as lead, with a collision energy of 1148 TeV.


A view of the LHC


Before being injected into the LHC, proton beams will be prepared by CERN's existing "accelerator complex". This is a succession of machines with increasingly higher energies, injecting the beam each time into the next one, which takes over to bring the beam to an even higher energy.


The CERN accelerator complex

To bend the 7 TeV protons around the ring, the LHC dipoles must be able to produce magnetic fields of 8.36 Tesla, a value which is made possible by the use of "superconductivity". This is the ability of certain materials, usually at very low temperatures, to conduct electric current without resistance and power losses, and therefore produce high magnetic fields. The LHC will operate at about 300 degrees below room temperature (even colder than outer space!) and use the most advanced superconducting magnet and accelerator technologies ever employed. 1,296 superconducting dipoles and more than 2,500 other magnets will guide and collide the LHC beams. They range from small, normally conducting bending magnets to large, superconducting focusing quadrupoles. When completed, the accelerator will be the largest superconducting installation in the world.

Monday, September 8, 2008

View Of LHC


Previous ImageOverall view of LHC experiments.Next Image

The LHC is installed in a tunnel ranging from 50 to 150 metres underground. Particle detectors called Alice, Atlas, CMS and LHCb surround the points at which particles collide, measuring the emerging showers of particles. The tunnel crosses the French-Swiss border six times, with the particle beams making 66000 border crossings per second.

The end of the world is not nigh

  • Tom Feilden
  • Fri 5 Sep 08, 07:29 AM

cern203.jpgDon't panic!

The world is not going to end when scientists switch on theLarge Hadron Collider (the giant atom smashing machine buried under the Swiss Alps) on Wednesday. That's the verdict of an exhaustive safety assessment.

Some scientists have voiced fears that switching on the LHC could trigger a black hole that would swallow the planet (and the rest of the solar system for good measure) in a matter of minutes. Led by a German chemist, Otto Rossler, they're using the European Convention on Human Rights to try and block the launch - which is due to be covered live on the Today programme.

The LHC is the biggest and most complex scientific instrument ever built, and at £4.4bn, it's also one of the most expensive experiments in history. It's designed to smash together beams of protons travelling at nearly the speed of light triggering a massive release of energy....so massive that it will recreate the conditions that existed in the universe just a trillionth of a second after the Big Bang.

Physicists hope the results could help solve some of our most fundamental questions about the nature of the material world, reveal the secrets of dark matter, and even point the way to a theory of everything.


Today's report provides the most comprehensive assessment on the safety of the project to date. It shows that the LHC almost certainly will produce microscopic black holes (perhaps at a rate as high as one every second) but that these will be so small and unstable that they vanish as quickly as they form.

The scientists point to the evidence from cosmic rays, which regularly produce much more powerful particle collisions than the LHC as they bombard the earth....and we haven't been swallowed by a black hole yet.

For more information on the LHC go to Radio 4's Big Bang website.

    Count Number Of Words In A Given File

    import java.util.*; // Provides TreeMap, Iterator, Scanner
    import java.io.*; // Provides FileReader, FileNotFoundException

    public class CountNumOfWords
    {
    public static void main(String[] args) 
    TreeMap frequencyData = new TreeMap( );

    readWordFile(frequencyData); 
    printAllCounts(frequencyData);
    }

    public static int getCount(String word, TreeMap frequencyData)
    {
    if (frequencyData.containsKey(word))
    { // The word has occurred before, so get its count from the map
    return frequencyData.get(word); // Auto-unboxed
    }
    else
    { // No occurrences of this word
    return 0;
    }
    }

    public static void printAllCounts(TreeMap frequencyData)
    {
    System.out.println("-----------------------------------------------");
    System.out.println(" Occurrences Word");

    for(String word : frequencyData.keySet( ))
    {
    System.out.printf("%15d %s\n", frequencyData.get(word), word);
    }

    System.out.println("-----------------------------------------------");

    public static void readWordFile(TreeMap frequencyData)
    {
    Scanner wordFile;
    String word; // A word read from the file
    Integer count; // The number of occurrences of the word

    try
    {
    wordFile = new Scanner(new FileReader("c:/Profile.java"));
    }
    catch (FileNotFoundException e)
    {
    System.err.println(e);
    return;
    }

    while (wordFile.hasNext())
    {
    // Read the next word and get rid of the end-of-line marker if needed:
    word = wordFile.next();

    // Get the current count of this word, add one, and then store the new count:
    count = getCount(word, frequencyData) + 1;
    frequencyData.put(word, count);
    }

    }

    String Tokenizer

    import java.util.*;

    public class StringTokenizer1{
        public static void main(String s[]){
    String name="Daniel.java";
    StringTokenizer st=new StringTokenizer(name,".");
    System.out.println(st.countTokens());
    while(st.hasMoreTokens()){
                System.out.println(st.nextToken());
    }
    }
    }

    Another Example Of Date Check

    function checkdate(objName) {

    var datefield = objName;


    if (chkdate(objName) == false) {

    datefield.select();

    alert("That date is invalid.  Please try again.");

    datefield.focus();

    return false;

    }

    else {
    return true;
       }
    }

    function chkdate(objName) {
    //var strDatestyle = "US"; //United States date style
    var strDatestyle = "EU";  //European date style
    var strDate;
    var strDateArray;
    var strDay;
    var strMonth;
    var strYear;
    var intday;
    var intMonth;
    var intYear;
    var booFound = false;
    var datefield = objName;
    var strSeparatorArray = new Array("-"," ","/",".");
    var intElementNr;
    var err = 0;
    var strMonthArray = new Array(12);
    strMonthArray[0] = "Jan";
    strMonthArray[1] = "Feb";
    strMonthArray[2] = "Mar";
    strMonthArray[3] = "Apr";
    strMonthArray[4] = "May";
    strMonthArray[5] = "Jun";
    strMonthArray[6] = "Jul";
    strMonthArray[7] = "Aug";
    strMonthArray[8] = "Sep";
    strMonthArray[9] = "Oct";
    strMonthArray[10] = "Nov";
    strMonthArray[11] = "Dec";


    strDate = datefield.value;

    if (strDate.length <>
    return true;
    }

    for (intElementNr = 0; intElementNr <>

    if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {

    strDateArray = strDate.split(strSeparatorArray[intElementNr]);

    if (strDateArray.length != 3) {

    err = 1;

    return false;

    }

    else {

    strDay = strDateArray[0];
    strMonth = strDateArray[1];
    strYear = strDateArray[2];

    }
    booFound = true;
       }
    }
    if (booFound == false) {
    if (strDate.length>5) {
    strDay = strDate.substr(0, 2);
    strMonth = strDate.substr(2, 2);
    strYear = strDate.substr(4);
       }
    }
    if (strYear.length == 2) {
    strYear = '20' + strYear;
    }
    // US style
    if (strDatestyle == "US") {
    strTemp = strDay;
    strDay = strMonth;
    strMonth = strTemp;
    }
    intday = parseInt(strDay, 10);
    if (isNaN(intday)) {
    err = 2;
    return false;
    }
    intMonth = parseInt(strMonth, 10);
    if (isNaN(intMonth)) {
    for (i = 0;i<12;i++)>
    if (strMonth.toUpperCase() == strMonthArray.toUpperCase()) {
    intMonth = i+1;
    strMonth = strMonthArray;
    i = 12;
       }
    }
    if (isNaN(intMonth)) {
    err = 3;
    return false;
       }
    }
    intYear = parseInt(strYear, 10);
    if (isNaN(intYear)) {
    err = 4;
    return false;
    }
    if (intMonth>12 || intMonth<1)>
    err = 5;
    return false;
    }
    if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday <>
    err = 6;
    return false;
    }
    if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday <>
    err = 7;
    return false;
    }

    if (intMonth == 2) {

    if (intday <>
    err = 8;
    return false;
    }
    if (LeapYear(intYear) == true) {
    if (intday > 29) {
    err = 9;
    return false;
    }
    }
    else {
    if (intday > 28) {
    err = 10;
    return false;
    }
    }
    }
    if (strDatestyle == "US") {
    datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
    }
    else {
    datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
    }
    return true;
    }



    function LeapYear(intYear) {
    if (intYear % 100 == 0) {
    if (intYear % 400 == 0) { return true; }
    }
    else {
    if ((intYear % 4) == 0) { return true; }
    }
    return false;
    }


    function doDateCheck(to) {
    //alert(document.form.to.value);
    var d=new Date();
    var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
    //Ensure correct for language. English is "January 1, 2004"
    var TODAY = d.getDate() + "- " +monthname[d.getMonth()] + "- " + d.getFullYear();
    //alert(Date.parse(TODAY));
    if (TODAY <= to.value)
    {
    alert("The date is valid.");
    }
    else
    alert(" date must occur GREATER THAN SYSDATE date.");
      
    }

    Get Age Based On Year Entered

    function calAge(bDay){
     var born;
     now = new Date()
     bD = bDay.value.split('-');
     if(bD.length!=3){
       alert('Date Is Not Valid'); 
      MyForm.age.value="";
     }
     else if(bD.length==3){
    born = new Date(bD[2], bD[1]*1-1, bD[0]);
     years = Math.floor((now.getTime() - born.getTime()) / (365.25 * 24 * 60 * 60 * 1000));
        MyForm.age.value = years;
     }
    }

    java Code to Retrive ref cursor info

    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;

    public class GetCursor {
     public static void main(String[] args){
     int ret_code;
     Connection conn = null;
     try {
      //Load and register Oracle driver
      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
     //Establish a connection

     conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.100.1:1521:server", "bond", "bond");

     String i_etype = "SENIOR";
     CallableStatement cstmt = conn.prepareCall("{ call REF_CURSOR_TEST. GET_ACCOUNTS_PROCEDURE(?)}");
     cstmt.registerOutParameter(1, OracleTypes.CURSOR);
     //cstmt.setString(2, i_etype);
     System.out.println("Before");
     cstmt.executeUpdate();
    System.out.println("After");
     ResultSet rset;
     rset = ((OracleCallableStatement)cstmt).getCursor(1);
     String str = "";
     while (rset.next()){
      /*str += rset.getString(1)+" 
        "+ rset.getInt(2)+" 
        "+rset.getString(3)+" 
        "+rset.getFloat(4)+" 
        "+rset.getFloat(5)+" 
        "+rset.getInt(6)+"\n";
     byte buf[] = str.getBytes();
     OutputStream fp = new FileOutputStream("senior.lst");
     fp.write(buf);
     fp.close();*/
             System.out.println("Record\t"+"Value"+rset.getInt(1));
    System.out.println("Record Value"+rset.getString(2));

     }
     rset.close();
     cstmt.close();
     conn.close();
      } 
      catch (Exception e) {
     /*ret_code = e.getErrorCode(); 
          System.err.println(ret_code + e.getMessage()); conn.close();*/
     }
     /*  catch (IOException e) { System.err.println
          ("Java File I/O Error:"+ e.getMessage()); }*/
     }
    }

    Ref Cursor Usage

    CREATE OR REPLACE PACKAGE REF_CURSOR_TEST IS

    TYPE T_ACCOUNTS_CURSOR IS REF CURSOR;
    PROCEDURE GET_ACCOUNTS_PROCEDURE (P_ACCOUNTS OUT T_ACCOUNTS_CURSOR);

    END REF_CURSOR_TEST;
    /

    CREATE OR REPLACE PACKAGE BODY REF_CURSOR_TEST IS

    PROCEDURE GET_ACCOUNTS_PROCEDURE (
    P_ACCOUNTS OUT T_ACCOUNTS_CURSOR
    ) AS
    BEGIN
    OPEN P_ACCOUNTS FOR 
    SELECT
    Id,Name
    FROM refs;
    END GET_ACCOUNTS_PROCEDURE;

    END REF_CURSOR_TEST;
    /