ceLax WorkZhttp://celax.me.ht
quality service, with affordable priceTue, 15 Feb 2011 12:59:58 +0000enhourly1http://wordpress.org/?v=3.0.5noquality service, with affordable priceA Java Applicationhttp://celax.me.ht/2011/02/a-java-application/
http://celax.me.ht/2011/02/a-java-application/#commentsMon, 14 Feb 2011 03:01:38 +0000celaxhttp://celax.me.ht/?p=119
Java refers to a number of computer software products and specifications from Sun Microsystems, a subsidiary of Oracle Corporation, that together provide a system for developing application software and deploying it in a cross-platform environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones on the low end, to enterprise servers and supercomputers on the high end. Java is used in mobile phones, Web servers and enterprise applications, and while less common on desktop computers, Java applets are sometimes used to provide improved and secure functionalities while browsing the World Wide Web.
Writing in the Java programming language is the primary way to produce code that will be deployed as Java bytecode, though there are bytecode compilers available for other languages such as Ada, JavaScript, Python, and Ruby. Several new languages have been designed to run natively on the Java Virtual Machine (JVM), such as Scala, Clojure and Groovy. Java syntax borrows heavily from C and C++, but object-oriented features are modeled after Smalltalk and Objective-C.Java eliminates certain low-level constructs such as pointers and has a very simple memory model where every object is allocated on the heap and all variables of object types are references. Memory management is handled through integrated automatic garbage collection performed by the JVM.
On November 13, 2006, Sun Microsystems made the bulk of its implementation of Java available under the GNU General Public License, although there are still a few parts distributed as precompiled binaries due to copyright issues with code that is licensed (but not owned) by Sun.
]]>http://celax.me.ht/2011/02/a-java-application/feed/0Java Training Philippines: Comprehensive Introduction to Java™ Programminghttp://celax.me.ht/2011/02/java-training-philippines-comprehensive-introduction-to-java%e2%84%a2-programming/
http://celax.me.ht/2011/02/java-training-philippines-comprehensive-introduction-to-java%e2%84%a2-programming/#commentsTue, 01 Feb 2011 06:54:10 +0000celaxhttp://celax.me.ht/?p=102Course Benefits:

Active Learning’s Java training program teaches you how to write Java applications that can run across multiple platforms seamlessly and reliably.

This Java training course provides extensive experience with the Java language and its object-oriented features. In this Java training course, you use Java to create text-based and GUI applications. Active Learning provides other Java training courses covering more advanced technologies. You can see related Java training courses below. Recently updated to cover the Java 6 platform, this course will also benefit professionals who wish to take the Sun Certified Java Programmer (SCJP) certification.

The instructor brings with him a wealth of corporate and training experience on disciplines of enterprise Java development. A Sun Certified Java Programmer, his passion is to help individuals maximize their potential as Java developers. He continues to receive encores in his training programs as he inspires learning and application in various areas of Java technology.

This Java Training course is for organizations and individuals who are looking for ways to create robust, object-oriented applications using Java technology. Prior structured programming experience is required. Understanding of Object-Oriented Programming (OOP) is helpful, but not required.

]]>http://celax.me.ht/2011/02/java-training-philippines-comprehensive-introduction-to-java%e2%84%a2-programming/feed/0Java in Actionhttp://celax.me.ht/2011/02/java-in-action/
http://celax.me.ht/2011/02/java-in-action/#commentsTue, 01 Feb 2011 06:46:24 +0000celaxhttp://celax.me.ht/?p=96Java technology is everywhere! In lots of familiar places, and in many places that might surprise you. Check out these Java in Action stories to discover some of the amazing ways that Java technology is involved in your life.

]]>http://celax.me.ht/2011/02/free-java-download-download-java-for-your-desktop-computer-now/feed/0The Single Java Object: Introducing the Singletonhttp://celax.me.ht/2011/01/the-single-java-object-introducing-the-singleton/
http://celax.me.ht/2011/01/the-single-java-object-introducing-the-singleton/#commentsMon, 31 Jan 2011 02:28:25 +0000celaxhttp://celax.me.ht/?p=92No, this isn’t a dating guide for the romantic Java developer, but an introduction to the singleton design pattern.

For those who haven’t heard of design patterns before, or who are familiar with the term but not its meaning, a design pattern is a template for software development. The purpose of the template is to define a particular behavior or technique that can be used as a building block for the construction of software – to solve universal problems that commonly face developers. Think of design code as a way of passing on some nifty piece of advice, just like your mother used to give. “Never wear your socks for more than one day” might be an old family adage, passed down from generation to generation. It’s common sense solutions that are passed on to others. Consider a design pattern as a useful piece of advice for designing software.

Design patterns out of the way, let’s look at the singleton. By now, you’re probably wondering what a singleton is – isn’t jargon terrible? A singleton is an object that cannot be instantiated. At first, that might seem counterintuitive – after all, we need an instance of an object before we can use it. Well yes a singleton can be created, but it can’t be instantiated by developers – meaning that the singleton class has control over how it is created. The restriction on the singleton is that there can be only one instance of a singleton created by the Java Virtual Machine (JVM) – by prevent direct instantiation we can ensure that developers don’t create a second copy.

So why would this be useful? Often in designing a system, we want to control how an object is used, and prevent others (ourselves included) from making copies of it or creating new instances. For example, a central configuration object that stores setup information should have one and one only instance – a global copy accessible from any part of the application, including any threads that are running. Creating a new configuration object and using it would be fairly useless, as other parts of the application might be looking at the old configuration object, and changes to application settings wouldn’t always be acted upon. I’m sure you can think of a other situations where a singleton would be useful – perhaps you’ve even used one before without giving it a name. It’s a common enough design criteria (not used everyday, but you’ll come across it from time to time). The singleton pattern can be applied in any language, but since we’re all Java programmers here (if you’re not, shame!) let’s look at how to implement the pattern using Java.

Preventing direct instantiation

We all know how objects are instantiated right? Maybe not everyone? Let’s go through a quick refresher.

Objects are instantiated by using the new keyword. The new keyword allows you to create a new instance of an object, and to specify parameters to the class’s constructor. You can specify no parameters, in which case the blank constructor (also known as the default constructor) is invoked. Constructors can have access modifiers, like public and private, which allow you to control which classes have access to a constructor. So to prevent direct instantiation, we create a private default constructor, so that other classes can’t create a new instance.

We’ll start with the class definition, for a SingletonObject class. Next, we provide a default constructor that is marked as private. No actual code needs to be written, but you’re free to add some initialization code if you’d like.

So far so good. But unless we add some further code, there’ll be absolutely no way to use the class. We want to prevent direct instantiation, but we still need to allow a way to get a reference to an instance of the singleton object.

Getting an instance of the singleton

We need to provide an accessor method, that returns an instance of the SingletonObject class but doesn’t allow more than one copy to be accessed. We can manually instantiate an object, but we need to keep a reference to the singleton so that subsequent calls to the accessor method can return the singleton (rather than creating a new one). To do this, provide a public static method called getSingletonObject(), and store a copy of the singleton in a private member variable.

So far, so good. When first called, the getSingletonObject() method creates a singleton instance, assigns it to a member variable, and returns the singleton. Subsequent calls will return the same singleton, and all is well with the world. You could extend the functionality of the singleton object by adding new methods, to perform the types of tasks your singleton needs. So the singleton is done, right? Well almost…..

Preventing thread problems with your singleton

We need to make sure that threads calling the getSingletonObject() method don’t cause problems, so it’s advisable to mark the method as synchronized. This prevents two threads from calling the getSingletonObject() method at the same time. If one thread entered the method just after the other, you could end up calling the SingletonObject constructor twice and returning different values. To change the method, just add the synchronized keyword as follows to the method declaration :-

public static synchronized
SingletonObject getSingletonObject()

Are we finished yet?

There, finished. A singleton object that guarantees one instance of the class, and never more than one. Right? Well…. not quite. Where there’s a will, there’s a way – it is still possible to evade all our defensive programming and create more than one instance of the singleton class defined above. Here’s where most articles on singletons fall down, because they forget about cloning. Examine the following code snippet, which clones a singleton object.

Okay, we’re cheating a little here. There isn’t a clone() method defined in SingletonObject, but there is in the java.lang.Object class which it is inherited from. By default, the clone() method is marked as protected, but if your SingletonObject extends another class that does support cloning, it is possible to violate the design principles of the singleton. So, to be absolutely positively 100% certain that a singleton really is a singleton, we must add a clone() method of our own, and throw a CloneNotSupportedException if anyone dares try!

Here’s the final source code for a SingletonObject, which you can use as a template for your own singletons.
public class SingletonObject
{
private SingletonObject()
{
// no code req'd
}

A singleton is an class that can be instantiated once, and only once. This is a fairly unique property, but useful in a wide range of object designs. Creating an implementation of the singleton pattern is fairly straightforward – simple block off access to all constructors, provide a static method for getting an instance of the singleton, and prevent cloning.

Object creation in Java is one of the most expensive operation in terms of memory utilization and performance impact. It is thus advisable to create or initialize an object only when it is required in the code.

Making a class field public can cause lot of issues in a program. For instance you may have a class called MyCalender. This class contains an array of String weekdays. You may have assume that this array will always contain 7 names of weekdays. But as this array is public, it may be accessed by anyone. Someone by mistake also may change the value and insert a bug!

But writing getter method does not exactly solve our problem. The array is still accessible. Best way to make it unmodifiable is to return a clone of array instead of array itself. Thus the getter method will be changed to.

public String[] getWeekdays() {
return weekdays.clone();
}

Quote 3: Always try to minimize Mutability of a class

Making a class immutable is to make it unmodifiable. The information the class preserve will stay as it is through out the lifetime of the class. Immutable classes are simple, they are easy to manage. They are thread safe. They makes great building blocks for other objects.

However creating immutable objects can hit performance of an app. So always choose wisely if you want your class to be immutable or not. Always try to make a small class with less fields immutable.

To make a class immutable you can define its all constructors private and then create a public static method
to initialize and object and return it.

First you can not inherit multiple classes in Java but you can definitely implements multiple interfaces. Its very easy to change the implementation of an existing class and add implementation of one more interface rather then changing full hierarchy of class.

Again if you are 100% sure what methods an interface will have, then only start coding that interface. As it is very difficult to add a new method in an existing interface without breaking the code that has already implemented it. On contrary a new method can be easily added in Abstract class without breaking existing functionality.

Quote 5: Always try to limit the scope of Local variable

Local variables are great. But sometimes we may insert some bugs due to copy paste of old code. Minimizing the scope of a local variable makes code more readable, less error prone and also improves the maintainability of the code.

Thus, declare a variable only when needed just before its use.

Always initialize a local variable upon its declaration. If not possible at least make the local instance assigned null value.

Quote 6: Try to use standard library instead of writing your own from scratch

Writing code is fun. But “do not reinvent the wheel”. It is very advisable to use an existing standard library which is already tested, debugged and used by others. This not only improves the efficiency of programmer but also reduces chances of adding new bugs in your code. Also using a standard library makes code readable and maintainable.

For instance Google has just released a new library Google Collections that can be used if you want to add advance collection functionality in your code.

Wrapper classes are great. But at same time they are slow. Primitive types are just values, whereas Wrapper classes are stores information about complete class.

Sometimes a programmer may add bug in the code by using wrapper due to oversight. For example, in below example:

int x = 10;
int y = 10;

Integer x1 = new Integer(10);
Integer y1 = new Integer(10);

System.out.println(x == y);
System.out.println(x1 == y1);

The first sop will print true whereas the second one will print false. The problem is when comparing two wrapper class objects we cant use == operator. It will compare the reference of object and not its actual value.

Also if you are using a wrapper class object then never forget to initialize it to a default value. As by default all wrapper class objects are initialized to null.

The above code will give a NullPointerException as it tries to box the values before comparing with true and as its null.

Quote 8: Use Strings with utmost care.

Always carefully use Strings in your code. A simple concatenation of strings can reduce performance of program. For example if we concatenate strings using + operator in a for loop then everytime + is used, it creates a new String object. This will affect both memory usage and performance time.

Also whenever you want to instantiate a String object, never use its constructor but always instantiate it directly. For example:

Whenever your method is returning a collection element or an array, always make sure you return empty array/collection and not null. This will save a lot of if else testing for null elements. For instance in below example we have a getter method that returns employee name. If the name is null it simply return blank string “”.

Defensive copies are the clone objects created to avoid mutation of an object. For example in below code we have defined a Student class which has a private field birth date that is initialized when the object is constructed.

In above code we just created a Student object with some default birthdate. But then we changed the value of year of the birthdate. Thus when we print the birth date, its year was changed to 2019!

To avoid such cases, we can use Defensive copies mechanism. Change the constructor of Student class to following.

public Student(birthDate) {
this.birthDate = new Date(birthDate);
}

This ensure we have another copy of birthdate that we use in Student class.
Two bonus quotes

Here are two bonus Java best practice quotes for you.

Quote 11: Never let exception come out of finally block

Finally blocks should never have code that throws exception. Always make sure finally clause does not throw exception. If you have some code in finally block that does throw exception, then log the exception properly and never let it come out

Quote 12: Never throw “Exception”

Never throw java.lang.Exception directly. It defeats the purpose of using checked Exceptions. Also there is no useful information getting conveyed in caller method.

More Quotes from Java Developers

Do you have a quote that is not included in above list? Well, feel free to add your Java best practice quote using comment below. Write your quote and explain it in 2-3 lines. I will add all those user generated quotes in this section.

Quote #13: Avoid floating point numbers

It is a bad idea to use floating point to try to represent exact quantities like monetary amounts. Using floating point for dollars-and-cents calculations is a recipe for disaster. Floating point numbers are best reserved for values such as measurements, whose values are fundamentally inexact to begin with. For calculations of monetary amounts it is better to use BigDecimal.

public class OddEven {
// "input" is the number that the user gives to the computer
private int input; // a whole number("int" means integer)

/*
* This is the constructor method. It gets called when an object of the OddEven type
* is being created.
*/
public OddEven() {
/*
* In most Java programs constructors can initialize objects with default values, or create
* other objects that this object might use to perform its functions. In some Java programs, the
* constructor may simply be an empty function if nothing needs to be initialized prior to the
* functioning of the object. In this program's case, an empty constructor would suffice, even if
* it is empty. A constructor must exist, however if the user doesn't put one in then the compiler
* will create an empty one.
*/
}

// This is the main method. It gets called when this class is run through a Java interpreter.
public static void main(String[] args) {
/*
* This line of code creates a new instance of this class called "number" (also known as an
* Object) and initializes it by calling the constructor. The next line of code calls
* the "showDialog()" method, which brings up a prompt to ask you for a number
*/
OddEven number = new OddEven();
number.showDialog();
}

public void showDialog() {
/*
* "try" makes sure nothing goes wrong. If something does,
* the interpreter skips to "catch" to see what it should do.
*/
try {
/*
* The code below brings up a JOptionPane, which is a dialog box
* The String returned by the "showInputDialog()" method is converted into
* an integer, making the program treat it as a number instead of a word.
* After that, this method calls a second method, calculate() that will
* display either "Even" or "Odd."
*/
input = Integer.parseInt(JOptionPane.showInputDialog("Please Enter A Number"));
calculate();
} catch (NumberFormatException e) {
/*
* Getting in the catch block means that there was a problem with the format of
* the number. Probably some letters were typed in instead of a number.
*/
System.err.println("ERROR: Invalid input. Please type in a numerical value.");
}
}

* The import statement imports the JOptionPane class from the javax.swing package.
* The OddEven class declares a single private field of type int named input. Every instance of the OddEven class has its own copy of the input field. The private declaration means that no other class can access (read or write) the input field.
* OddEven() is a public constructor. Constructors have the same name as the enclosing class they are declared in, and unlike a method, have no return type. A constructor is used to initialize an object that is a newly created instance of the class.
* The calculate() method is declared without the static keyword. This means that the method is invoked using a specific instance of the OddEven class. (The reference used to invoke the method is passed as an undeclared parameter of type OddEven named this.) The method tests the expression input % 2 == 0 using the if keyword to see if the remainder of dividing the input field belonging to the instance of the class by two is zero. If this expression is true, then it prints Even; if this expression is false it prints Odd. (The input field can be equivalently accessed as this.input, which explicitly uses the undeclared this parameter.)
* OddEven number = new OddEven(); declares a local object reference variable in the main method named number. This variable can hold a reference to an object of type OddEven. The declaration initializes number by first creating an instance of the OddEven class, using the new keyword and the OddEven() constructor, and then assigning this instance to the variable.
* The statement number.showDialog(); calls the calculate method. The instance of OddEven object referenced by the number local variable is used to invoke the method and passed as the undeclared this parameter to the calculate method.
* input = Integer.parseInt(JOptionPane.showInputDialog(“Please Enter A Number”)); is a statement that converts the type of String to the primitive data type int by using a utility function in the primitive wrapper class Integer.

Most programmers will be familiar with sequence. A sequence of programming statements are executed one after the other. For example, the following two lines can be executed sequentially

System.out.println (“hello”);
System.out.println (“goodbye”);

Selection is also fairly simple. By using if / switch statements, you can control the execution flow of code. Most programmers are already familiar with the concept behind if statements – it is virtually impossible to write any application without using some form of selection.

The final concept, iteration, is the focus of this article. This one is a little more tricky, as there are quite a few different times of iteration statements in Java. The basic concept behind iteration, is that a sequence of statements is repeated until a certain condition is met. When this condition is met, the iteration terminates, and the loop is over.

‘for’ loops

The simplest type of loop uses the for statement, to iterate through a sequence of statements. Usually, a for loop will use a counter, with a precise starting point and a precise ending point.

There are several components to a for loop
for ( init ; condition ; statement )

A check to see if the condition equates to true is made at the end of the for loop. When the condition fails to be met, the loop will terminate. In our previous example, the loop terminates when our counter (i) is not less than or equal to a value of five.

It is also worth noting that each of the components of a for loop is entirely optional. For example, our loop could be rewritten as the following: -

// This may be more useful, as the variable
// i is created outside the scope of the
// loop.
int i = 1;

A while loop differs from the for loop, in that it only contains a condition, and that the condition is tested at the beginning of the loop. This means that if the condition evaluates to false, it will not be executed at all. We call this a pre-tested loop, because the test is made before executing the sequence of statements contained within.

int i = 1;

while (i <= 5)
{
System.out.println ("count : " + i);
i++;
}

'do...while' loops

A variation on the while loop is the post-tested version. Two keywords are used for this loop, the do and the while keywords.

int i = 1;

do
{
System.out.println ("count : " + i);
i++;
}
while (i <= 5)

There is no difference between a while, and a do...while loop other than pre-testing and post-testing.
Terminating loops abruptly

Sometimes it is necessary to stop a loop before its terminating condition is reached. For example, a loop that searched through an array for a particular entry should not continue once that entry is found - to do so would only waste CPU time and make for a slower program. Other times, you may want to skip ahead to the next iteration of the loop, rather than performing additional processing. Java provides two keywords for this purpose : break and continue.
break

The break keyword is used to terminate a loop early. Consider the following example, which searches through an array for a particular value.

Unlike the break keyword, continue does not terminate a loop. Rather, it skips to the next iteration of the loop, and stops executing any further statements in this iteration. This allows us to bypass the rest of the statements in the current sequence, without stopping the next iteration through the loop.

While this example was unnecessary, since we had an if statement to separate prog

]]>http://celax.me.ht/2011/01/is-java-driving-you-loopy/feed/0Inside Java : Java myths – fact versus fictionhttp://celax.me.ht/2011/01/inside-java-java-myths-fact-versus-fiction/
http://celax.me.ht/2011/01/inside-java-java-myths-fact-versus-fiction/#commentsSat, 29 Jan 2011 11:04:00 +0000celaxhttp://celax.me.ht/?p=65There are so many myths about Java. This month, I’ll look at some of the more persistent ones, and try to dispel any doubt.

Fiction : Applets can read your hard-drive, and delete files

Fact :Any attempt by an applet to access local files will throw a SecurityException. If uncaught, the applet will crash, but no file access will occur.

The only exception to this rule is for digitally signed applets, which may be granted additional privileges. Your browser will display a dialog box, asking you if you want to accept the identity of the applet author. Choose no if unsure, and you’ll always be safe.

Fact :Java code comes in many forms. The most familiar to users is the applet, which runs inside a web browser. However, this is only the tip of the iceberg.

Java applications can be run just like normal programs. By installing a JVM from vendors like Sun or Microsoft, you gain the ability to run Java programs. It’s just like normal programs, such as Microsoft Word.

Java servlets run inside a web server. Servlets are a replacement for CGI scripts, and Active Server Pages (ASP). Servlets are actually really fast, and can be more efficient than CGI scripts.

Fiction : Java is a hundred times slower than C, so you shouldn’t ever use it for “serious” programming.

Fact :Fiction :The original Java Virtual Machines were slow, so slow that a comparable C application was about twenty times faster. The gap between C/C++ and Java is growing smaller though, thanks to better designed JVMs, and Just-In-Time (JIT) compilers that convert bytecode to native machine code at runtime.

Much of the cause for speed concerns is actually over applet loading – large applets take a long time to load initially. Thankfully, Java applications and servlets are not subject to such slow loading times.

Fiction : There’s no point learning any language other than Java – it will dominate the software industry and put C++ programmers out of work.

Fact :There are many languages suited to very narrow and specific tasks (such as artificial intelligence) that Java will never overcome. While it is true that Java has had phenomenal growth, and significantly eroded the role of C++, it still has a long way to go. Java excels in portability and Internet support – but C++ still offers better performance and the ability to interact with the operating system.

Fiction : Applets are inherently unreliable. The differences between Netscape and Internet Explorer make it impossible to write stable applets.

Fact :The problems with the behavior of applets running under browsers is due to the different JVMs – between browsers and browser versions. These differences can be frustrating for developers and users. There are often workarounds though, and applets should always be tested with a variety of browsers.

The optimal solution is to use a single JVM, which will be used across all browsers. Sound like fantasy? Sun Microsystems, the creators of Java, have come up with the Java Plug-in. The Java Plug-in bypasses the browser’s JVM, and uses its own. This means that users with the plug-in installed can always rely on uniform performance, regardless of which browser they use. For more information, see the Java Plug-in page.

Summary

Java actually holds a lot more potential than many people realize. It’s more than just applets – Java software can run inside a web server, or standalone. However, Java isn’t the only programming language around, and it’s wise to learn at least the basics of a language like C++, Visual Basic, or Delphi. Java applets are secure, and won’t delete your hard drive. And if you find that applets aren’t working properly in one browser but do in another, consider using the Java Plug-in.

]]>http://celax.me.ht/2011/01/inside-java-java-myths-fact-versus-fiction/feed/0Inside Java : The Java Virtual Machinehttp://celax.me.ht/2011/01/inside-java-the-java-virtual-machine/
http://celax.me.ht/2011/01/inside-java-the-java-virtual-machine/#commentsSat, 29 Jan 2011 10:58:55 +0000celaxhttp://celax.me.ht/?p=59At the heart of the Java platform lies the Java Virtual Machine, or JVM. Most programming languages compile source code directly into machine code, suitable for execution on a particular microprocessor architecture. The difference with Java is that it uses bytecode – a special type of machine code.

Java bytecode executes on a special type of microprocessor. Strangely enough, there wasn’t a hardware implementation of this microprocessor available when Java was first released. Instead, the processor architecture is emulated by what is known as a “virtual machine”. This virtual machine is an emulation of a real Java processor – a machine within a machine (Figure One). The only difference is that the virtual machine isn’t running on a CPU – it is being emulated on the CPU of the host machine.

Figure One – JVM emulation run on a physical CPU

The Java Virtual Machine is responsible for interpreting Java bytecode, and translating this into actions or operating system calls. For example, a request to establish a socket connection to a remote machine will involve an operating system call. Different operating systems handle sockets in different ways – but the programmer doesn’t need to worry about such details. It is the responsibility of the JVM to handle these translations, so that the operating system and CPU architecture on which Java software is running is completely irrelevant to the developer.

Figure Two – JVM handles translations

The Java Virtual Machine forms part of a large system, the Java Runtime Environment (JRE). Each operating system and CPU architecture requires a different JRE. The JRE comprises a set of base classes, which are an implementation of the base Java API, as well as a JVM. The portability of Java comes from implementations on a variety of CPUs and architectures. Without an available JRE for a given environment, it is impossible to run Java software.

Differences between JVM implementations

Though implementations of Java Virtual Machines are designed to be compatible, no two JVMs are exactly alike. For example, garbage collection algorithms vary between one JVM and another, so it becomes impossible to know exactly when memory will be reclaimed. The thread scheduling algorithms are different between one JVM and another (based in part on the underlying operating system), so that it is impossible to accurately predict when one thread will be executed over another.

Initially, this is a cause for concern from programmers new to the Java language. However, it actually has very little practical bearing on Java development. Such predictions are often dangerous to make, as thread scheduling and memory usage will vary between different hardware environments anyway. The power of Java comes from not being specific about the operating system and CPU architecture – to do so reduces the portability of software.

Summary

The Java Virtual Machine provides a platform-independent way of executing code, by abstracting the differences between operating systems and CPU architectures. Java Runtime Environments are available for a wide variety of hardware and software combinations, making Java a very portable language. Programmers can concentrate on writing software, without having to be concerned with how or where it will run. The idea of virtual machines is nothing new, but Java is the most widely used virtual machine used today. Thanks to the JVM, the dream of Write Once-Run Anywhere (WORA) software has become a reality.