<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ceLax WorkZ</title>
	<atom:link href="http://celax.me.ht/feed/" rel="self" type="application/rss+xml" />
	<link>http://celax.me.ht</link>
	<description>quality service, with affordable price</description>
	<lastBuildDate>Tue, 15 Feb 2011 12:59:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>A Java Application</title>
		<link>http://celax.me.ht/2011/02/a-java-application/</link>
		<comments>http://celax.me.ht/2011/02/a-java-application/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 03:01:38 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Mobile]]></category>
		<category><![CDATA[Java Technologies]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Java Application]]></category>
		<category><![CDATA[java download]]></category>
		<category><![CDATA[java technologies]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=119</guid>
		<description><![CDATA[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. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://celax.me.ht/2011/02/a-java-application/jt-atlantic-cinema-en/" rel="attachment wp-att-121"><img src="http://celax.me.ht/wp-content/uploads/2011/02/jt-atlantic-cinema-en.jpg" alt="java application" title="jt-atlantic-cinema-en" width="648" height="397" class="alignleft size-full wp-image-121" /></a><br />
<a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> is used in mobile phones, Web servers and enterprise applications, and while less common on desktop computers, <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> applets are sometimes used to provide improved and secure functionalities while browsing the World Wide Web.<br />
Writing in the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> programming language is the primary way to produce code that will be deployed as <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Virtual Machine (JVM), such as Scala, Clojure and Groovy. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> syntax borrows heavily from C and C++, but object-oriented features are modeled after Smalltalk and Objective-C.<a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.<br />
On November 13, 2006, Sun Microsystems made the bulk of its implementation of <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/02/a-java-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Training Philippines: Comprehensive Introduction to Java™ Programming</title>
		<link>http://celax.me.ht/2011/02/java-training-philippines-comprehensive-introduction-to-java%e2%84%a2-programming/</link>
		<comments>http://celax.me.ht/2011/02/java-training-philippines-comprehensive-introduction-to-java%e2%84%a2-programming/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 06:54:10 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java Training]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java training]]></category>
		<category><![CDATA[SCJP]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=102</guid>
		<description><![CDATA[Course Benefits: Active Learning&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Course Benefits:</strong></p>
<p>Active Learning&#8217;s <a href="http://celax.me.ht/tag/java-training-2/" class="st_tag internal_tag" rel="tag" title="Posts tagged with java training">Java training</a> program teaches you how to write <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> applications that can run across multiple platforms seamlessly and reliably.</p>
<p>This <a href="http://celax.me.ht/tag/java-training-2/" class="st_tag internal_tag" rel="tag" title="Posts tagged with java training">Java training</a> course provides extensive experience with the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> language and its object-oriented features. In this <a href="http://celax.me.ht/tag/java-training-2/" class="st_tag internal_tag" rel="tag" title="Posts tagged with java training">Java training</a> course, you use <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> to create text-based and GUI applications. Active Learning provides other <a href="http://celax.me.ht/tag/java-training-2/" class="st_tag internal_tag" rel="tag" title="Posts tagged with java training">Java training</a> courses covering more advanced technologies. You can see related <a href="http://celax.me.ht/tag/java-training-2/" class="st_tag internal_tag" rel="tag" title="Posts tagged with java training">Java training</a> courses below. Recently updated to cover the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 6 platform, this course will also benefit professionals who wish to take the Sun Certified <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Programmer (SCJP) certification.</p>
<p>The instructor brings with him a wealth of corporate and training experience on disciplines of enterprise <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> development. A Sun Certified <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Programmer, his passion is to help individuals maximize their potential as <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> developers. He continues to receive encores in his training programs as he inspires learning and application in various areas of <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> technology.</p>
<p><strong>You will learn how to:</strong></p>
<p>    * Write, compile, and execute a <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> program using the Eclipse IDE<br />
    * Learn Object-Oriented Programming concepts such as inheritance and polymorphism<br />
    * Create simple GUI applications with AWT and Swing using <strong>NetBeans IDE</strong><br />
    * Use <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a>&#8217;s exception handling framework<br />
    * Write efficient applications through multi-threading<br />
    * Read and write files<br />
    * Access databases using JDBC</p>
<p><strong>Who Should Attend:</strong></p>
<p>This <a href="http://celax.me.ht/tag/java-training-2/" class="st_tag internal_tag" rel="tag" title="Posts tagged with java training">Java Training</a> course is for organizations and individuals who are looking for ways to create robust, object-oriented applications using <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> technology. Prior structured programming experience is required. Understanding of Object-Oriented Programming (OOP) is helpful, but not required.</p>
<p><strong>Course Content</strong></p>
<p>    * Introduction to <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a><br />
    * <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Language Fundamentals<br />
    * <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Development Overview Using Eclipse<br />
    * Control Flow Structures<br />
    * Arrays<br />
    * Object-Oriented Programming<br />
    * Creating Your Own Classes<br />
    * Inheritance, Polymorphism, and Advanced OOP Concepts<br />
    * Exception Handling<br />
    * Essential <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> classes, Collections, and Generics<br />
    * GUI Programming with AWT and Swing using NetBeans<br />
    * Event handling<br />
    * Multi-threading<br />
    * I/O Streams and Files<br />
    * Access databases using JDBC</p>
<p><strong>Upcoming Dates</strong></p>
<p>    * Feb 28 &#8211; Mar 4, 2011 (8:30am &#8211; 5:30pm)<br />
    * Weekend Classes: Feb 19, 26, Mar 5, 12, 19, 2011 (8:30am &#8211; 5:30pm)</p>
<p><strong>Course Investment</strong></p>
<p>    * For pricing info, call us at +632 726-8128 or Email us.<br />
    * Money Saving Tuition Plans</p>
<p><strong>Related Courses</strong></p>
<p>    * 611 &#8211; Object-Oriented Analysis and Design Using UML<br />
    * 323 &#8211; Developing <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Web Applications<br />
    * 341 &#8211; Struts Web Application Framework</p>
<p><em><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> is a registered trademark of Sun Microsystems, Inc. in the United States and other countries. </em></p>
<p><a href="http://www.activelearning.ph/courses/321_java_training_philippines.html"><strong>Original Article</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/02/java-training-philippines-comprehensive-introduction-to-java%e2%84%a2-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java in Action</title>
		<link>http://celax.me.ht/2011/02/java-in-action/</link>
		<comments>http://celax.me.ht/2011/02/java-in-action/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 06:46:24 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java Technologies]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java article]]></category>
		<category><![CDATA[java in action]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=96</guid>
		<description><![CDATA[Java 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 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> technology is everywhere! In lots of familiar places, and in many places that might surprise you. Check out these <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> in Action stories to discover some of the amazing ways that <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> technology is involved in your life. </p>
<p>Find <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> in Action <a href="http://www.java.com/en/java_in_action/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/02/java-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Java Download: Download Java for your desktop computer now!</title>
		<link>http://celax.me.ht/2011/02/free-java-download-download-java-for-your-desktop-computer-now/</link>
		<comments>http://celax.me.ht/2011/02/free-java-download-download-java-for-your-desktop-computer-now/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 06:44:30 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java Download]]></category>
		<category><![CDATA[Java Technologies]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java download]]></category>
		<category><![CDATA[java in action]]></category>
		<category><![CDATA[java technologies]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=94</guid>
		<description><![CDATA[Download: Version 6 Why download Java? Java technology allows you to work and play in a secure computing environment. Java allows you to play online games, chat with people around the world, calculate your mortgage [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.java.com/en/download/index.jsp">Download: Version 6</a></p>
<p><strong>Why download <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a>?</strong></p>
<p><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> technology allows you to work and play in a secure computing environment.</p>
<p><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> allows you to play online games, chat with people around the world, calculate your mortgage interest, and view images in 3D, just to name a few.</p>
<p>After you&#8217;ve downloaded <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a>, visit <a href="http://www.java.com">java.com</a> to check out <a href="http://celax.me.ht/2011/02/java-in-action">Java in Action</a> in your daily life. </p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/02/free-java-download-download-java-for-your-desktop-computer-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Single Java Object: Introducing the Singleton</title>
		<link>http://celax.me.ht/2011/01/the-single-java-object-introducing-the-singleton/</link>
		<comments>http://celax.me.ht/2011/01/the-single-java-object-introducing-the-singleton/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 02:28:25 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java article]]></category>
		<category><![CDATA[java singleton]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=92</guid>
		<description><![CDATA[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. ]]></description>
			<content:encoded><![CDATA[<p>No, this isn&#8217;t a dating guide for the romantic <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> developer, but an introduction to the singleton design pattern.</p>
<p>For those who haven&#8217;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 &#8211; 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. &#8220;Never wear your socks for more than one day&#8221; might be an old family adage, passed down from generation to generation. It&#8217;s common sense solutions that are passed on to others. Consider a design pattern as a useful piece of advice for designing software.</p>
<p>Design patterns out of the way, let&#8217;s look at the singleton. By now, you&#8217;re probably wondering what a singleton is &#8211; isn&#8217;t jargon terrible? A singleton is an object that cannot be instantiated. At first, that might seem counterintuitive &#8211; after all, we need an instance of an object before we can use it. Well yes a singleton can be created, but it can&#8217;t be instantiated by developers &#8211; 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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Virtual Machine (JVM) &#8211; by prevent direct instantiation we can ensure that developers don&#8217;t create a second copy.</p>
<p>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 &#8211; 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&#8217;t always be acted upon. I&#8217;m sure you can think of a other situations where a singleton would be useful &#8211; perhaps you&#8217;ve even used one before without giving it a name. It&#8217;s a common enough design criteria (not used everyday, but you&#8217;ll come across it from time to time). The singleton pattern can be applied in any language, but since we&#8217;re all <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> programmers here (if you&#8217;re not, shame!) let&#8217;s look at how to implement the pattern using <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a>.</p>
<p><strong>Preventing direct instantiation</strong></p>
<p>We all know how objects are instantiated right? Maybe not everyone? Let&#8217;s go through a quick refresher.</p>
<p>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&#8217;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&#8217;t create a new instance.</p>
<p>We&#8217;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&#8217;re free to add some initialization code if you&#8217;d like. </p>
<p><code>public class SingletonObject<br />
{<br />
	private SingletonObject()<br />
	{<br />
		// no code req'd<br />
	}<br />
}</code></p>
<p>So far so good. But unless we add some further code, there&#8217;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.</p>
<p><strong>Getting an instance of the singleton</strong></p>
<p>We need to provide an accessor method, that returns an instance of the SingletonObject class but doesn&#8217;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.</p>
<p><code>public class SingletonObject<br />
{<br />
    private SingletonObject()<br />
    {<br />
        // no code req'd<br />
    }</p>
<p>    public static SingletonObject getSingletonObject()<br />
    {<br />
      if (ref == null)<br />
          // it's ok, we can call this constructor<br />
          ref = new SingletonObject();<br />
      return ref;<br />
    }</p>
<p>    private static SingletonObject ref;<br />
}</code></p>
<p>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&#8230;..</p>
<p><strong>Preventing thread problems with your singleton</strong></p>
<p>We need to make sure that threads calling the getSingletonObject() method don&#8217;t cause problems, so it&#8217;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 :-</p>
<p><code>public static synchronized<br />
	 SingletonObject getSingletonObject()</code></p>
<p>Are we finished yet?</p>
<p>There, finished. A singleton object that guarantees one instance of the class, and never more than one. Right? Well&#8230;. not quite. Where there&#8217;s a will, there&#8217;s a way &#8211; it is still possible to evade all our defensive programming and create more than one instance of the singleton class defined above. Here&#8217;s where most articles on singletons fall down, because they forget about cloning. Examine the following code snippet, which clones a singleton object.</p>
<p><code>public class Clone<br />
{<br />
	public static void main(String args[])<br />
	  throws Exception<br />
	{<br />
	  // Get a singleton<br />
	  SingletonObject obj =<br />
	  SingletonObject.getSingletonObject();</p>
<p>	  // Buahahaha. Let's clone the object<br />
	  SingletonObject clone =<br />
		(SingletonObject) obj.clone();<br />
	}<br />
}</code></p>
<p>Okay, we&#8217;re cheating a little here. There isn&#8217;t a clone() method defined in SingletonObject, but there is in the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">java</a>.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!</p>
<p>Here&#8217;s the final source code for a SingletonObject, which you can use as a template for your own singletons.<br />
<code><br />
public class SingletonObject<br />
{<br />
  private SingletonObject()<br />
  {<br />
    // no code req'd<br />
  }</p>
<p>  public static SingletonObject getSingletonObject()<br />
  {<br />
    if (ref == null)<br />
        // it's ok, we can call this constructor<br />
        ref = new SingletonObject();<br />
    return ref;<br />
  }</p>
<p>  public Object clone()<br />
	throws CloneNotSupportedException<br />
  {<br />
    throw new CloneNotSupportedException();<br />
    // that'll teach 'em<br />
  }</p>
<p>  private static SingletonObject ref;<br />
}</code></p>
<p><strong>Summary</strong></p>
<p>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 &#8211; simple block off access to all constructors, provide a static method for getting an instance of the singleton, and prevent cloning. </p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/01/the-single-java-object-introducing-the-singleton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Most Useful Java Best Practice Quotes for Java Developers</title>
		<link>http://celax.me.ht/2011/01/10-most-useful-java-best-practice-quotes-for-java-developers/</link>
		<comments>http://celax.me.ht/2011/01/10-most-useful-java-best-practice-quotes-for-java-developers/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 14:23:01 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java article]]></category>
		<category><![CDATA[java codes]]></category>
		<category><![CDATA[java tips]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=83</guid>
		<description><![CDATA[Quote 1: Avoid creating unnecessary objects and always prefer to do Lazy Initialization Object creation in Java is one of the most expensive operation in terms of memory utilization and performance impact. It is thus [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Quote 1: Avoid creating unnecessary objects and always prefer to do Lazy Initialization </p></blockquote>
<p>Object creation in <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</p>
<p><code>public class Countries {</p>
<p>    private List countries;</p>
<p>    public List getCountries() {</p>
<p>        //initialize only when required<br />
        if(null == countries) {<br />
            countries = new ArrayList();<br />
        }<br />
        return countries;<br />
    }<br />
}</code></p>
<blockquote><p>Quote 2: Never make an instance fields of class public</p></blockquote>
<p>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!</p>
<p><code>public class MyCalender {</p>
<p>    public String[] weekdays =<br />
        {"Sun", "Mon", "Tue", "Thu", "Fri", "Sat", "Sun"};</p>
<p>    //some code</p>
<p>}</code></p>
<p>Best approach as many of you already know is to always make the field private and add a getter method to access the elements.</p>
<p><code>private String[] weekdays =<br />
    {"Sun", "Mon", "Tue", "Thu", "Fri", "Sat", "Sun"};</p>
<p>public String[] getWeekdays() {<br />
    return weekdays;<br />
}</code></p>
<p>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.</p>
<p><code>public String[] getWeekdays() {<br />
    return weekdays.clone();<br />
}</code></p>
<blockquote><p>Quote 3: Always try to minimize Mutability of a class</p></blockquote>
<p>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.</p>
<p>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.</p>
<p>To make a class immutable you can define its all constructors private and then create a public static method<br />
to initialize and object and return it.</p>
<p><code>public class Employee {</p>
<p>    private String firstName;<br />
    private String lastName;</p>
<p>    //private default constructor<br />
    private Employee(String firstName, String lastName) {<br />
        this.firstName = firstName;<br />
        this.lastName = lastName;<br />
    }</p>
<p>    public static Employee valueOf (String firstName, String lastName) {<br />
        return new Employee(firstName, lastName);<br />
    }<br />
}</code></p>
<blockquote><p>Quote 4: Try to prefer Interfaces instead of Abstract classes</p></blockquote>
<p>First you can not inherit multiple classes in <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</p>
<p>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.</p>
<blockquote><p>Quote 5: Always try to limit the scope of Local variable</p></blockquote>
<p>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.</p>
<p>Thus, declare a variable only when needed just before its use.</p>
<p>Always initialize a local variable upon its declaration. If not possible at least make the local instance assigned null value.</p>
<blockquote><p>Quote 6: Try to use standard library instead of writing your own from scratch</p></blockquote>
<p>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.</p>
<p>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.</p>
<blockquote><p>Quote 7: Wherever possible try to use Primitive types instead of Wrapper classes</p></blockquote>
<p>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.</p>
<p>Sometimes a programmer may add bug in the code by using wrapper due to oversight. For example, in below example:</p>
<p><code>int x = 10;<br />
int y = 10;</p>
<p>Integer x1 = new Integer(10);<br />
Integer y1 = new Integer(10);</p>
<p>System.out.println(x == y);<br />
System.out.println(x1 == y1);</code></p>
<p>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.</p>
<p>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.</p>
<p><code>Boolean flag;</p>
<p>if(flag == true) {<br />
    System.out.println("Flag is set");<br />
} else {<br />
    System.out.println("Flag is not set");<br />
}</code></p>
<p>The above code will give a NullPointerException as it tries to box the values before comparing with true and as its null.</p>
<blockquote><p>Quote 8: Use Strings with utmost care.</p></blockquote>
<p>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.</p>
<p>Also whenever you want to instantiate a String object, never use its constructor but always instantiate it directly. For example:</p>
<p><code>//slow instantiation<br />
String slow = new String("Yet another string object");</p>
<p>//fast instantiation<br />
String fast = "Yet another string object";</code></p>
<blockquote><p>Quote 9: Always return empty Collections and Arrays instead of null</p></blockquote>
<p>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 “”.</p>
<p><code>public String getEmployeeName() {<br />
    return (null==employeeName ? "": employeeName);<br />
}</code></p>
<blockquote><p>Quote 10: Defensive copies are savior</p></blockquote>
<p>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.</p>
<p><code>public class Student {<br />
    private Date birthDate;</p>
<p>    public Student(birthDate) {<br />
        this.birthDate = birthDate;<br />
    }</p>
<p>    public Date getBirthDate() {<br />
        return this.birthDate;<br />
    }<br />
}<br />
</code></p>
<p>Now we may have some other code that uses the Student object.</p>
<p><code>public static void main(String []arg) {</p>
<p>    Date birthDate = new Date();<br />
    Student student = new Student(birthDate);</p>
<p>    birthDate.setYear(2019);</p>
<p>    System.out.println(student.getBirthDate());<br />
}</code></p>
<p>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!</p>
<p>To avoid such cases, we can use Defensive copies mechanism. Change the constructor of Student class to following.</p>
<p><code>public Student(birthDate) {<br />
    this.birthDate = new Date(birthDate);<br />
}<br />
</code><br />
This ensure we have another copy of birthdate that we use in Student class.<br />
Two bonus quotes</p>
<p>Here are two bonus <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> best practice quotes for you.</p>
<blockquote><p>Quote 11: Never let exception come out of finally block</p></blockquote>
<p>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 <img src='http://celax.me.ht/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<blockquote><p>Quote 12: Never throw “Exception”</p></blockquote>
<p>Never throw <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">java</a>.lang.Exception directly. It defeats the purpose of using checked Exceptions. Also there is no useful information getting conveyed in caller method.</p>
<p><strong>More Quotes from <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Developers</strong></p>
<p>Do you have a quote that is not included in above list? Well, feel free to add your <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</p>
<blockquote><p>Quote #13: Avoid floating point numbers</p></blockquote>
<p>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.</p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/01/10-most-useful-java-best-practice-quotes-for-java-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Programming: A more comprehensive example</title>
		<link>http://celax.me.ht/2011/01/java-programming-a-more-comprehensive-example/</link>
		<comments>http://celax.me.ht/2011/01/java-programming-a-more-comprehensive-example/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 14:10:13 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java article]]></category>
		<category><![CDATA[java basic]]></category>
		<category><![CDATA[java tips]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=79</guid>
		<description><![CDATA[// OddEven.java import javax.swing.JOptionPane; 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 [...]]]></description>
			<content:encoded><![CDATA[<p><code>// OddEven.<a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">java</a><br />
import javax.swing.JOptionPane;</p>
<p>public class OddEven {<br />
    // "input" is the number that the user gives to the computer<br />
    private int input; // a whole number("int" means integer)</p>
<p>    /*<br />
     * This is the constructor method. It gets called when an object of the OddEven type<br />
     * is being created.<br />
     */<br />
    public OddEven() {<br />
    /*<br />
     * In most <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> programs constructors can initialize objects with default values, or create<br />
     * other objects that this object might use to perform its functions. In some <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> programs, the<br />
     * constructor may simply be an empty function if nothing needs to be initialized prior to the<br />
     * functioning of the object.  In this program's case, an empty constructor would suffice, even if<br />
     * it is empty. A constructor must exist, however if the user doesn't put one in then the compiler<br />
     * will create an empty one.<br />
     */<br />
    }</p>
<p>    // This is the main method. It gets called when this class is run through a <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> interpreter.<br />
    public static void main(String[] args) {<br />
        /*<br />
         * This line of code creates a new instance of this class called "number" (also known as an<br />
         * Object) and initializes it by calling the constructor.  The next line of code calls<br />
         * the "showDialog()" method, which brings up a prompt to ask you for a number<br />
         */<br />
        OddEven number = new OddEven();<br />
        number.showDialog();<br />
    }</p>
<p>    public void showDialog() {<br />
        /*<br />
         * "try" makes sure nothing goes wrong. If something does,<br />
         * the interpreter skips to "catch" to see what it should do.<br />
         */<br />
        try {<br />
            /*<br />
             * The code below brings up a JOptionPane, which is a dialog box<br />
             * The String returned by the "showInputDialog()" method is converted into<br />
             * an integer, making the program treat it as a number instead of a word.<br />
             * After that, this method calls a second method, calculate() that will<br />
             * display either "Even" or "Odd."<br />
             */<br />
            input = Integer.parseInt(JOptionPane.showInputDialog("Please Enter A Number"));<br />
            calculate();<br />
        } catch (NumberFormatException e) {<br />
            /*<br />
             * Getting in the catch block means that there was a problem with the format of<br />
             * the number. Probably some letters were typed in instead of a number.<br />
             */<br />
            System.err.println("ERROR: Invalid input. Please type in a numerical value.");<br />
        }<br />
    }</p>
<p>    /*<br />
     * When this gets called, it sends a message to the interpreter.<br />
     * The interpreter usually shows it on the command prompt (For Windows users)<br />
     * or the terminal (For Linux users).(Assuming it's open)<br />
     */<br />
    private void calculate() {<br />
        if (input % 2 == 0) {<br />
            System.out.println("Even");<br />
        } else {<br />
            System.out.println("Odd");<br />
        }<br />
    }<br />
}<br />
</code></p>
<li>
<ul>
* The import statement imports the JOptionPane class from the javax.swing package.<br />
    * 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.<br />
    * 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.<br />
    * 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.)<br />
    * 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.<br />
    * 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.<br />
    * input = Integer.parseInt(JOptionPane.showInputDialog(&#8220;Please Enter A Number&#8221;)); 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.</ul>
</li>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/01/java-programming-a-more-comprehensive-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Java driving you loopy?</title>
		<link>http://celax.me.ht/2011/01/is-java-driving-you-loopy/</link>
		<comments>http://celax.me.ht/2011/01/is-java-driving-you-loopy/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 11:07:09 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[introduction to java]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=67</guid>
		<description><![CDATA[There are three basic building blocks of programming :- sequence selection iteration Most programmers will be familiar with sequence. A sequence of programming statements are executed one after the other. For example, the following two [...]]]></description>
			<content:encoded><![CDATA[<p>There are three basic building blocks of programming :-</p>
<ul>
sequence<br />
selection<br />
iteration </ul>
<p>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</p>
<p>System.out.println (&#8220;hello&#8221;);<br />
System.out.println (&#8220;goodbye&#8221;);</p>
<p>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 &#8211; it is virtually impossible to write any application without using some form of selection.</p>
<p>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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a>. 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.</p>
<p>&#8216;for&#8217; loops</p>
<p>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.</p>
<p>// for loop, from 1 to 5<br />
<code>for (int i = 1; i <= 5; i++)<br />
{<br />
    System.out.println ("count : " + i);<br />
}</code></p>
<p>There are several components to a for loop<br />
<code><br />
for ( init   ;   condition   ;   statement ) </code></p>
<p>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.</p>
<p>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: -</p>
<p><code>// This may be more useful, as the variable<br />
// i is created outside the scope of the<br />
// loop.<br />
int i = 1;</p>
<p>// for loop, from i to 5<br />
for (; i <= 5; i++)<br />
{<br />
    System.out.println ("count : " + i);<br />
} </code></p>
<p><strong>'while' loops</strong></p>
<p>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.</p>
<p><code>int i = 1;</p>
<p>while (i <= 5)<br />
{<br />
    System.out.println ("count : " + i);<br />
    i++;<br />
}</p>
<p>'do...while' loops</code></p>
<p>A variation on the while loop is the post-tested version. Two keywords are used for this loop, the do and the while keywords.</p>
<p><code>int i = 1;</p>
<p>do<br />
{<br />
    System.out.println ("count : " + i);<br />
    i++;<br />
}<br />
while (i <= 5)</code></p>
<p>There is no difference between a while, and a do...while loop other than pre-testing and post-testing.<br />
Terminating loops abruptly</p>
<p>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. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> provides two keywords for this purpose : break and continue.<br />
break</p>
<p>The break keyword is used to terminate a loop early. Consider the following example, which searches through an array for a particular value.</p>
<p><code>// Check to see if "yes" string is stored<br />
boolean foundYes = false;</p>
<p>for (int i = 0; i < array.length; i++)<br />
{<br />
    if (array[i].equals("yes"))<br />
    {<br />
        foundYes = true;<br />
        break;<br />
    }<br />
}<br />
</code><br />
<strong>continue</strong></p>
<p>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.</p>
<p><code>for (int i = 0; i < array.length; i++)<br />
{<br />
    if (array[i] == null)<br />
        // skip this one, goto next loop<br />
        continue;<br />
    else<br />
    {<br />
        // do something with array[i]<br />
        .......<br />
    }<br />
}</code></p>
<p>While this example was unnecessary, since we had an if statement to separate prog</p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/01/is-java-driving-you-loopy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inside Java : Java myths &#8211; fact versus fiction</title>
		<link>http://celax.me.ht/2011/01/inside-java-java-myths-fact-versus-fiction/</link>
		<comments>http://celax.me.ht/2011/01/inside-java-java-myths-fact-versus-fiction/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 11:04:00 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Application]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=65</guid>
		<description><![CDATA[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. ]]></description>
			<content:encoded><![CDATA[<p>There are so many myths about <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a>. This month, I&#8217;ll look at some of the more persistent ones, and try to dispel any doubt.</p>
<p><strong>Fiction : </strong><br />
<em>Applets can read your hard-drive, and delete files</em></p>
<p><strong>Fact :</strong><br />
<em>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.</em></p>
<p>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&#8217;ll always be safe.</p>
<p><strong>Fiction : </strong><br />
<em><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> requires a web browser. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> only runs in a web browser.</em></p>
<p><strong>Fact :</strong><br />
<em><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</em></p>
<p><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> applications can be run just like normal programs. By installing a JVM from vendors like Sun or Microsoft, you gain the ability to run <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> programs. It&#8217;s just like normal programs, such as Microsoft Word.</p>
<p><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</p>
<p><strong>Fiction : </strong><br />
<em><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> is a hundred times slower than C, so you shouldn&#8217;t ever use it for &#8220;serious&#8221; programming.</em></p>
<p><strong>Fact :</strong>Fiction :<br />
<em>The original <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Virtual Machines were slow, so slow that a comparable C application was about twenty times faster. The gap between C/C++ and <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> is growing smaller though, thanks to better designed JVMs, and Just-In-Time (JIT) compilers that convert bytecode to native machine code at runtime.</em></p>
<p>Much of the cause for speed concerns is actually over applet loading &#8211; large applets take a long time to load initially. Thankfully, <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> applications and servlets are not subject to such slow loading times. </p>
<p><strong>Fiction : </strong><br />
<em>There&#8217;s no point learning any language other than <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> &#8211; it will dominate the software industry and put C++ programmers out of work.</em></p>
<p><strong>Fact :</strong><br />
<em>There are many languages suited to very narrow and specific tasks (such as artificial intelligence) that <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> will never overcome. While it is true that <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> has had phenomenal growth, and significantly eroded the role of C++, it still has a long way to go. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> excels in portability and Internet support &#8211; but C++ still offers better performance and the ability to interact with the operating system.</em></p>
<p><strong>Fiction : </strong><br />
<em>Applets are inherently unreliable. The differences between Netscape and Internet Explorer make it impossible to write stable applets.</em></p>
<p><strong>Fact :</strong><br />
<em>The problems with the behavior of applets running under browsers is due to the different JVMs &#8211; 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.</em></p>
<p>The optimal solution is to use a single JVM, which will be used across all browsers. Sound like fantasy? Sun Microsystems, the creators of <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a>, have come up with the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Plug-in. The <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Plug-in bypasses the browser&#8217;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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Plug-in page.</p>
<p><strong>Summary</strong></p>
<p><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> actually holds a lot more potential than many people realize. It&#8217;s more than just applets &#8211; <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> software can run inside a web server, or standalone. However, <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> isn&#8217;t the only programming language around, and it&#8217;s wise to learn at least the basics of a language like C++, Visual Basic, or Delphi. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> applets are secure, and won&#8217;t delete your hard drive. And if you find that applets aren&#8217;t working properly in one browser but do in another, consider using the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Plug-in. </p>
<p>By <a href="http://www.javacoffeebreak.com/articles/inside_java/insidejava-may00.html">David Reilly</a></p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/01/inside-java-java-myths-fact-versus-fiction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inside Java : The Java Virtual Machine</title>
		<link>http://celax.me.ht/2011/01/inside-java-the-java-virtual-machine/</link>
		<comments>http://celax.me.ht/2011/01/inside-java-the-java-virtual-machine/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 10:58:55 +0000</pubDate>
		<dc:creator>celax</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[jre]]></category>
		<category><![CDATA[Programming Languages]]></category>

		<guid isPermaLink="false">http://celax.me.ht/?p=59</guid>
		<description><![CDATA[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.]]></description>
			<content:encoded><![CDATA[<p>At the heart of the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> platform lies the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> is that it uses bytecode &#8211; a special type of machine code. </p>
<p><a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> bytecode executes on a special type of microprocessor. Strangely enough, there wasn&#8217;t a hardware implementation of this microprocessor available when <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> was first released. Instead, the processor architecture is emulated by what is known as a &#8220;virtual machine&#8221;. This virtual machine is an emulation of a real <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> processor &#8211; a machine within a machine (Figure One). The only difference is that the virtual machine isn&#8217;t running on a CPU &#8211; it is being emulated on the CPU of the host machine.</p>
<p> <a href="http://celax.me.ht/wp-content/uploads/2011/01/dec99figureone.gif"><img src="http://celax.me.ht/wp-content/uploads/2011/01/dec99figureone.gif" alt="Java Virtual Machine" title="dec99figureone" width="313" height="223" class="alignnone size-full wp-image-60" /></a></p>
<p>Figure One &#8211; JVM emulation run on a physical CPU</p>
<p>The <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Virtual Machine is responsible for interpreting <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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 &#8211; but the programmer doesn&#8217;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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> software is running is completely irrelevant to the developer.</p>
<p> <a href="http://celax.me.ht/wp-content/uploads/2011/01/dec99figureone1.gif"><img src="http://celax.me.ht/wp-content/uploads/2011/01/dec99figureone1.gif" alt="Java Runtime Environment" title="dec99figureone" width="433" height="406" class="alignnone size-full wp-image-61" /></a></p>
<p>Figure Two &#8211; JVM handles translations</p>
<p>The <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Virtual Machine forms part of a large system, the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> API, as well as a JVM. The portability of <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> comes from implementations on a variety of CPUs and architectures. Without an available JRE for a given environment, it is impossible to run <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> software.</p>
<p><strong>Differences between JVM implementations</strong></p>
<p>Though implementations of <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</p>
<p>Initially, this is a cause for concern from programmers new to the <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> language. However, it actually has very little practical bearing on <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> development. Such predictions are often dangerous to make, as thread scheduling and memory usage will vary between different hardware environments anyway. The power of <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> comes from not being specific about the operating system and CPU architecture &#8211; to do so reduces the portability of software.</p>
<p><strong>Summary</strong></p>
<p>The <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Virtual Machine provides a platform-independent way of executing code, by abstracting the differences between operating systems and CPU architectures. <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> Runtime Environments are available for a wide variety of hardware and software combinations, making <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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 <a href="http://celax.me.ht/tag/java/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Java">Java</a> 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.</p>
<p>By <a href="http://www.javacoffeebreak.com/articles/inside_java/insidejava-jan99.html">David Reilly</a></p>
]]></content:encoded>
			<wfw:commentRss>http://celax.me.ht/2011/01/inside-java-the-java-virtual-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
