tag:blogger.com,1999:blog-55993235670147037162024-03-13T02:11:58.110-07:00javapediaThis blog is dedicated to publish good articles on Java Technology.prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.comBlogger32125tag:blogger.com,1999:blog-5599323567014703716.post-19862247173493575742008-11-15T01:40:00.000-08:002008-11-15T01:42:09.071-08:00Is Sun's JavaFX RIA platform a RIA?It's been a long hype cycle for Sun's RIA strategy. JavaFx was first touted in 2007 and a public beta took almost a year to reach the hands of developers. While the official release is scheduled anytime between now and December, I can't help feel that Sun has lost momentum in a space it should own.<br /><br />Earlier this year Jonathan Schwartz, CEO of Sun Microsystems, claimed that Java has always been an RIA platform. Technically, he is correct -- Java is and was "write once, run anywhere (that has the Java virtual machine)" platform. For Sun, client-side Java never really took off for Web apps and to a large extent technology like Flash, and later AJAX, stole the show. Although Java at first stumbled with performance issues, it was on par with these technologies but never seem to marry the designer tools and the developer back-end know-how efficiently.<br /><br />Fast-forward to 2008 and Adobe is the clear leader in the RIA world and its investment in technologies like Flex and Air are pulling traditional Java developers away from aging technologies like Swing. On top of this Microsoft has stuck its RIA pole in the ground with Silverlight and is looking to drum up a large developer community with their technology stack. Microsoft is catching up fast.<br /><br />Sun is running behind. For a company that itself boasts penetration rates of its virtual machine to be 85% of desktops, 90% of handsets, and many home entertainment devices, the progress seems slow-going.<br /><br />Sun needs to be seen as innovating in this area. Technology decisions are made on progressive platforms which attract significant investment in time and resources by the company that produces it. It's simply not good enough to leave Java quietly chugging along in the corner, even if it is open source.<br /><br />If Sun can marry the client-side potential of JavaFX to the server-side it will be a huge boost to the company, the Java community, and related vendors who are powered by Java technology. If not, Java certainly won't go away, but it's not going to attract a great deal of new business.<br /><br />The stakes will be even higher in the embedded market for Sun, an area in which it has strong marketshare. With JavaFX for mobile devices due out in early to mid 2009 the company will need to show its platform is up to speed compared to stiff competition from Google's Java-powered Android phones, Microsoft's mobile platform, the iPhone, and other next-generation phones.<br /><br />Can Sun do it? Maybe it can. Will Java live on? Of course it will. With or without Sun in the picture Java will still be innovated by the likes of IBM, Google, and Oracle. The technology just needs a clear steward to take it to the next level.<br /><br />What do you think of Sun's efforts with JavaFX? Leave your thoughts in the comments section below.prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-43137250519665494702008-11-09T04:44:00.000-08:002008-11-09T04:57:58.671-08:00JavaFX<div class="Section1"> <p><span class="SpellE"><span style="">JavaFX</span></span> is a family of products for creating so called Rich Internet Applications, web applications that have the features and functionality of traditional desktop applications, including interactive multimedia applications. The <span class="SpellE">JavaFX</span> products can build applications for desktop, mobile, TV and other platforms.<o:p></o:p></p> <p><span class="SpellE">JavaFX</span> consists of <span class="SpellE">JavaFX</span> Script and <span class="SpellE">JavaFX</span> Mobile.<o:p></o:p></p> <p>The primary component of <span class="SpellE">JavaFX</span> is <span class="SpellE">JavaFX</span> Script, a declarative language, intended to make Swing easier to use for interface programmers or visual designers who might be more familiar with scripting languages. In <span class="SpellE">JavaFX</span> Script, the structure of the programming code is supposed to closely <span class="SpellE">matche</span> the actual layout of the GUI.<o:p></o:p></p> <p><span class="SpellE">JavaFX</span> Mobile is a Java operating system for mobile devices, including <span class="SpellE">PDAs</span>, <span class="SpellE">smartphones</span> and feature phones. It features a Java SE and Java ME implementation running on top of a Linux kernel.<o:p></o:p></p> <h2><span class="SpellE">JavaFX</span> Mobile<o:p></o:p></h2> <p class="MsoNormal" style=""><span class="SpellE">JavaFX</span> Mobile is a complete mobile operating and <span class="klink">application</span><span style="display: none;"><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:formulas> <v:path extrusionok="f" gradientshapeok="t" connecttype="rect"> <o:lock ext="edit" aspectratio="t"> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:16.5pt;"> <v:imagedata src="javafx_files/image001.gif" href="http://kona.kontera.com/javascript/lib/imgs/grey_loader.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///C:/DOCUME%7E1/JAYAPR%7E1/LOCALS%7E1/Temp/WordWebPagePreview/javafx_files/image001.gif" style="border-style: none; border-width: 0px;" shapes="_x0000_i1025" height="22" width="22" /><!--[endif]--><o:p></o:p></span></p> <p class="MsoNormal"><span style=""> </span><span class="GramE">environment</span> built around Java and Linux open source <span class="klink">technologies</span>. It is a complete, fully integrated Java software system for advanced mobile devices designed to enable developers to author rich, high-impact content and network-based services. Built around open and standards-based technologies, <span class="SpellE">JavaFX</span> Mobile enables control and flexibility for the mobile ecosystem.<br /><br />Being centralized around Java technologies, <span class="SpellE">JavaFX</span> <span class="klink">Mobile software</span> system provides a greater scalability and portability, speed time-to-market, and enhances the consistency of applications and services. Additionally, it also provides a support for Java ME applications and other standard <span class="klink">Java APIs</span> which enables a broad range of new and existing Java applications.<o:p></o:p></p> <p class="MsoNormal" style="">It is like the networking in your hand. It is based on open standards. <span class="SpellE">JavaFX</span> Mobile runs on all mobile phones with Java support e.g. Nokia N800.<o:p></o:p></p> <p class="MsoBodyText"><span class="SpellE">JavaFX</span> Mobile, Sun's software system for mobile devices, is available via OEM (i.e. Original equipment manufacturers) license to carriers, handset manufacturers and others seeking a branded relationship with consumers. Through OEM multiple companies can simplify and accelerate the development of powerful standardized software systems to leverage the power across a wide range of consumer devices. <o:p></o:p></p> <p class="MsoNormal" style="">Additionally, It allows content creators to create rich media content without relying on developers, allowing the drag and drop of <span class="klink">desktop</span> and mobile content, which is not possible with any other RIA. <o:p></o:p></p> <h4 style="margin: 0in 0in 0.0001pt;"><span style="font-weight: normal;">Get Ready for Dynamic Interactive Content on Any Device: </span><span style="font-weight: normal;">It is unpredictable to guess what devices or platforms the end user is using; however with <span class="SpellE">JavaFX</span>, you don't have to worry about the things. <span class="SpellE">JavaFX</span> Mobile uses industry standard technologies--this means that applications built with <span class="SpellE">JavaFX</span> can run on a wide range of Java-enabled devices, and content providers can add them to their devices quickly. <span class="SpellE">JavaFX</span> Mobile includes the latest standards, like the Mobile Services Architecture, set of device APIs, which allows developers to have a rich set of highly portable capabilities. </span><span style="font-weight: normal;"><o:p></o:p></span></h4> <p class="MsoNormal" style="">End users always look for an exciting and dynamic content on the web and expect a better interactive experience with <span class="klink">web services</span>. <span class="SpellE">JavaFX</span> helps in delivering visually compelling applications, such as maps and <span class="SpellE">mashups</span>, video, audio, and pictures, that is standardize across cell phones, TVs, and more. <o:p></o:p></p> <p class="MsoNormal" style=""><span style="">Reduced Integration Costs with Expanded Opportunities: I</span>mplementation of the majority of the solution in Java, including middleware and resident applications, <span class="SpellE">JavaFX</span> Mobile reduces integration costs, improves device software consistency, and enables device manufactures to provide new offerings with substantially faster time-to-market.<span style=""> </span><o:p></o:p></p> <p class="MsoNormal" style=""><span class="SpellE"><span style="">JavaFX</span></span><span style=""> Mobile Architecture: </span><o:p></o:p></p> <p style="margin: 0in 0in 0.0001pt;"><span class="SpellE">JavaFX</span> Mobile streamlines the environment and reduces reliance on underlying technologies by providing a complete middleware and application stack implemented in Java. <o:p></o:p></p> <p style="margin: 0in 0in 0.0001pt;"> <o:p></o:p></p> <p class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style="'width:386.25pt;height:162.75pt'"> <v:imagedata src="javafx_files/image002.gif" href="http://www.roseindia.net/Technology-revolution/javafx/javafx10.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///C:/DOCUME%7E1/JAYAPR%7E1/LOCALS%7E1/Temp/WordWebPagePreview/javafx_files/image002.gif" shapes="_x0000_i1026" border="0" height="217" width="515" /><!--[endif]--><o:p></o:p></p> <h2><span class="SpellE">JavaFX</span> Script<o:p></o:p></h2> <p class="MsoNormal" style=""><span class="SpellE">JavaFX</span> Script is a scripting language designed by Sun Microsystems, forming part of the <a href="http://en.wikipedia.org/wiki/JavaFX" title="JavaFX"><span class="SpellE"><span style="color: black;">JavaFX</span></span></a> family of technologies on the Java Platform. <span class="SpellE">JavaFX</span> targets the Rich Internet Application domain (competing with Adobe Flex and Microsoft <span class="SpellE">Silverlight</span>), specializing in rapid development of visually rich applications for the desktop and mobile markets. <span class="SpellE">JavaFX</span> Script works with integrated development environments like <a href="http://en.wikipedia.org/wiki/NetBeans" title="NetBeans"><span class="SpellE"><span style="color: black;">NetBeans</span></span></a> and Eclipse. <span class="SpellE">JavaFX</span> is released under the GNU General Public License, via the Sun sponsored <a href="https://openjfx.dev.java.net/" title="https://openjfx.dev.java.net"><span class="SpellE"><span style="color: black;">OpenJFX</span></span><span style="color: black;"> project</span></a>,<o:p></o:p></p> <h2><o:p> </o:p></h2> <p class="MsoNormal"><b><i><span style="font-size: 14pt; font-family: Arial;"><o:p> </o:p></span></i></b></p> </div>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-26669907908273951462008-11-09T04:08:00.000-08:002008-11-09T04:14:41.257-08:00Google Gmail for Mobile 2.0 Adds J2ME Support<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTsTo-COZRe_M6gjJEYAltS-h-6qlBYV8lkMt9x9QlU4_j0dawyq3Bd6AXYktzcUA8ScDltDFAPy3xDgnez21-Lnxd0a4fPwGJs7B3RNBYHR2s-D6sDzf5V1yUObT_KLoSRt-VHUNBGh0/s1600-h/google_gmail.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTsTo-COZRe_M6gjJEYAltS-h-6qlBYV8lkMt9x9QlU4_j0dawyq3Bd6AXYktzcUA8ScDltDFAPy3xDgnez21-Lnxd0a4fPwGJs7B3RNBYHR2s-D6sDzf5V1yUObT_KLoSRt-VHUNBGh0/s320/google_gmail.jpg" alt="" id="BLOGGER_PHOTO_ID_5266629327431759346" border="0" /></a><br />Google Inc on Thursday launched a new version of its Gmail for Mobile. Google Gmail offers J2ME support which includes mobile devices such as NOkia N95 and RIM BlackBerry mobile phones. The online Google Gmail application has better performance and smoother scrolling. <div id="boldbodytext"><strong>Google Gmail for Mobile 2.0 has been released. The updated Google Gmail application offers improved performance and smoother scrolling. Gmail users with multiple accounts can now switch between them without using different applications to view messages.</strong></div> <!-- 300x250 Advertisement --> <div class="ad300x250"> </div> <br /><p>Google Inc on Thursday released version 2 of its Google Gmail for Mobile application. Google Gmail has several nice features including support for offline access for the first time.</p><p>Google Gmail for Mobile 2.0 adds new support for J2ME-supported mobile phones. The Nokia N95 and BlackBerry mobile devices are some of the phones that use J2ME.</p>The new Gmail for Mobile application offers improved performance and speed. It also offerssmoother scrolling and fixes the "freeze" bug. Some mobile phones were freezing up while scrolling in Gmail.<p>"We re-architected the entire client to push all the processing to the background, greatly improve the client-side caching scheme and optimize every bottleneck piece of code we came across," Google software engineer, Derek Phillips, said in a statement.</p><p>The offline support lets users read and compose new emails offline. This feature also works when there's no 3G signal.</p><p>The mobile application now supports multiple accounts for Gmail. Users can also switch between accounts without using different applications to view messages. Gmail for Mobile 2.0 also offers support for smart phones that have a QWERTY keyboard. This feature lets users create shortcut keys for Gmail.</p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-48141443141389107372008-10-26T03:58:00.000-07:002008-10-26T04:28:12.755-07:00Debugging Java Code in the CVMCVM supports the JVMDI, so you can connect a JPDA debugger to it without involving a<br />separate debug proxy of the type used by KVM. However, before you can start debugging,<br />you need to do two things:<br /><br /><span style="font-weight: bold;">1.</span> Build the CVM with the CVM_DEBUG and CVM_JVMDI options to the make<br />command set to true.<br /><br /><span style="font-weight: bold;">2.</span> Build the library libjdwp, which contains the native code that implements the Java<br />Debug Wire Protocol (JDWP). This protocol allows debuggers to connect to the VM<br />over a socket or using shared memory.<br /><br />You can build libjdwp using the following commands:<br /><br /><span style="font-style: italic;">cd $CDC/ext/jpda/build/linux</span><br /><span style="font-style: italic;">make</span><br /><br />This creates the library and writes it to the file $CDC/jdk_build/linux/lib/i386/libjdwp.so.<br /><br />Starting CVM for debugging requires quite a long command line:<br /><br /><span style="font-style: italic;">cvm -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=5000</span><br /><span style="font-style: italic;">-Xbootclasspath:$CDC/build/linux/lib/foundation.jar -Dsun.boot.library.</span><br /><span style="font-style: italic;">path=$CDC/jdk_build/linux/lib/i386 -Djava.class.path=$EXAMPLES/src ora.</span><br /><span style="font-style: italic;">ch7.CVMProperties</span><br /><br />The options used here are as follows:<br /><br /><span style="font-weight: bold; color: rgb(153, 0, 0);">-Xdebug</span><br /><br />Starts the VM in debug mode. When this option is used, the VM suspends operation<br />before entering the main( ) method of the initial application class.<br /><br /><span style="font-weight: bold; color: rgb(153, 0, 0);">-Xrunjdwp</span><br /><br />Tells the VM to use JDWP for debugging. This option requires several parameters,<br />separated from it by a colon and from each other by commas, that specify how the<br />debugger will connect to the VM. In this case, the parameters supplied are as follows:<br /><br /> <span style="font-weight: bold; color: rgb(204, 102, 0);">transport=dt_socket</span><br /> Specifies that the debugger will connect over a socket.<br /><br /> <span style="font-weight: bold; color: rgb(204, 102, 0);">server=y</span><br /> Tells JDWP to take on the server role. The debugger itself acts as the client.<br /><br /> <span style="font-weight: bold; color: rgb(204, 102, 0);">address=5000</span><br /> Specifies the port number that the server should use to listen for a connection from the<br /> debugger client.<br /><br /><span style="font-weight: bold; color: rgb(204, 0, 0);">-Xbootclasspath</span><br /><br />Specifies the location of VM's boot classes, in this case the set of core and Foundation<br />Profile classes that have not been prelinked into the VM.<br /><br /><span style="font-weight: bold; color: rgb(204, 0, 0);">-Dsun.boot.library.path</span><br /><br />Gives the directory in which the JWDP implementation library (libjdwp.so for Linux)<br />can be found.<br /><br /><span style="font-weight: bold; color: rgb(204, 0, 0);">-Djava.class.path</span><br /><br />Specifies the locations to be searched for application classes.<br /><br />Once the CVM has started, it will suspend and wait for a debugger to connect to it on the port<br />specified in the -Xrunjdwp argument. If you have an IDE that supports remote JPDA<br />debugging (such as Forte for Java), you can use it to perform source- level debugging. Alternatively, you can use the command-line tool jdb, which is part of the J2SE SDK. To connect using jdb, you need to specify the socket address on which the VM is listening and the location at which the source code for the application's classes can be found:<br /><br /><span style="font-style: italic;">jdb -attach localhost:5000 -sourcepath $EXAMPLES/src</span><br /><br />Here, jdb and the CVM are assumed to be on the same machine, but this need not be the case.<br />Following connection, you need to use the step command to force the VM to enter the<br />main( ) method. From here, you can use jdb commands to set breakpoints, list the source<br />code around the line currently being executed, inspect and modify objects and fields, and so<br />on.<br /><br />By default, when you use the -Xdebug argument, the JVMDI support in the VM starts at the<br />same time as the VM itself and suspends execution until a debugger connects to it. However,<br />you can choose to have JVMDI defer its initialization until an exception of a named type or an<br />uncaught exception is thrown. The latter case is often the type of error that you would like to<br />use a debugger to investigate, but starting the VM in debug usually causes it to execute byte<br />codes more slowly. Using this feature, you can run the VM at full speed until the exception<br />occurs.<br /><br />The options that control the point at which the debugging features initialize is part of the -<br />Xrunjdwp argument. The following command:<br /><br /><span style="font-style: italic;">cvm -Xdebug -Xrunjdwp:transport=dt_</span><br /><span style="font-style: italic;">socket,server=y,address=5000,onuncaught=y -Xbootclasspath:$CDC/build/</span><br /><span style="font-style: italic;">linux/lib/foundation.jar -Dsun.boot.library.path=$CDC/jdk_build/linux/</span><br /><span style="font-style: italic;">lib/i386 -Djava.class.path=$EXAMPLES/src ora.ch7.CVMException</span><br /><br />adds the onuncaught option with value y, which delays initialization of the JVMDI until an<br />uncaught exception occurs. The class ora.ch7.CVMException used here waits for 10<br />seconds, then deliberately causes a NullPointerException that it does not catch, at which<br />point the debug facilities initialize and the VM is suspended. You can now start jdb to analyze<br />the problem.<br /><br />Alternatively, if you simply want to start debugging when a NullPointerException occurs,<br />use the onthrow option, which requires the class name of the exception to wait for:<br /><br /><span style="font-style: italic;">cvm -Xdebug -Xrunjdwp:transport=dt_</span><br /><span style="font-style: italic;">socket,server=y,address=5000,onthrow=java.lang.NullPointerException</span><br /><span style="font-style: italic;">-Xbootclasspath:$CDC/build/linux/lib/foundation.jar -Dsun.boot.library.</span><br /><span style="font-style: italic;">path=$CDC/jdk_build/linux/lib/i386 -Djava.class.path=$EXAMPLES/src</span><br /><span style="font-style: italic;">ora.ch7.CVMException</span><br /><br /><br />Finally, you can use the launch option to cause a command to be executed when the VM<br />debug facilities initialize. This option requires the name of the command, which should be<br />either an absolute path or the name of an executable on your search path (i.e., included in the<br />PATH variable for Linux). When it is started, the program receives the transport name and<br />address used by the debugger as arguments -- that is, it is effectively run with arguments like<br />this:<br /><br /><span style="font-style: italic;">name dt_socket 5000</span><br /><br />One way to make use of this is to create a script that starts jdb when the condition that starts<br />the JVMDI support occurs, like this:<br /><br /><span style="font-style: italic;">#!/bin/sh</span><br /><span style="font-style: italic;">jdb -attach localhost:$2 -sourcepath $EXAMPLES/src</span><br /><br />If you put these lines into a file called startdbg.sh (in a directory included in your PATH<br />variable) and make it executable (using a command like chmod +x startdbg.sh), the<br />following command:<br /><br /><span style="font-style: italic;">cvm -Xdebug -Xrunjdwp:transport=dt_</span><br /><span style="font-style: italic;">socket,server=y,address=5000,onthrow=java.lang.</span><br /><span style="font-style: italic;">NullPointerException,launch=startdbg.sh -Xbootclasspath:$CDC/build/</span><br /><span style="font-style: italic;">linux/lib/foundation.jar -Dsun.boot.library.path=$CDC/jdk_build/linux/</span><br /><span style="font-style: italic;">lib/i386 -Djava.class.path=$EXAMPLES/src ora.ch7.CVMException</span><br /><br />runs the VM until a NullPointerException occurs, at which point it initializes the JVMDI<br />code, suspends bytecode execution, and runs your script. This results in jdb starting and<br />connecting to the VM, using the port number that is passed as the second argument to the<br />script.prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-9935266429325822722008-10-04T04:06:00.000-07:002008-10-04T04:07:41.030-07:00MIDP GUI Programming<p>User interface requirements for handheld devices are different from those for desktop computers. For example, the display size of handheld devices is smaller, and input devices do not always include pointing tools such as a mouse or pen input. For these reasons, you cannot follow the same user-interface programming guidelines for applications running on handheld devices that you can on desktop computers.</p> The CLDC itself does not define any GUI functionality. Instead, the official GUI classes for the J2ME are included in profiles such as the MIDP and are defined by the Java Community Process (JCP). You'll note that the GUI classes included in the MIDP are not based on the Abstract Window Toolkit (AWT).<br /><a href="http://oreilly.com/catalog/wirelessjava/chapter/ch05.html"><br /><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-77199219023374115442008-10-04T02:33:00.000-07:002008-10-04T02:34:24.555-07:00Basic I/OThis article the Java platform classes used for basic I/O. It focuses primarily on <em>I/O Streams</em>, a powerful concept that greatly simplifies I/O operations. The article also looks at serialization, which lets a program write whole objects out to streams and read them back again. Then the article looks at some file system operations, including random access files. Finally, it touches briefly on the advanced features of the New I/O API. Most of the classes covered are in the <code>java.io</code> package.<br /><br /><a href="http://java.sun.com/docs/books/tutorial/essential/io/"><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-50678723385213610192008-10-04T02:14:00.000-07:002008-10-04T02:24:26.698-07:00Using and Programming Generics in J2SE 5.0<img alt=" " src="file:///C:/Documents%20and%20Settings/Jaya%20Prakash/Desktop/Java_Generics_files/image002.gif" shapes="_x0000_i1025" border="0" height="4" width="1" /><o:p></o:p> A Java collection is a flexible data structure that can hold heterogeneous objects where the elements may have any reference type. It is your responsibility, however, to keep track of what types of objects your collections contain. As an example, consider adding an <code><span style="font-size:10;">int</span></code> to a collection; since you cannot have collections of primitive data types you must convert the <code><span style="font-size:10;">int</span></code> to the corresponding reference type (i.e. <code><span style="font-size:10;">Integer</span></code>) before storing it in the collection. Now, when the element is extracted from the collection an Object is returned that must be cast to an <code><span style="font-size:10;">Integer</span></code> in order to ensure type safety. All this makes Java programs unnecessarily hard to read and maintain, and are more likely to fail with runtime errors. <o:p></o:p><br />If the compiler could keep track of the element type, you do not need to keep track of what collections you have and the need for casting would be eliminated. This would make programs easier to read and maintain, and less likely to fail at runtime. J2SE 5.0 has added a new core language feature known as generics (also known as parameterized types), that provides compile-time type safety for collections and eliminate the drudgery of casting. The effort of adding generics to Java is led by Sun Microsystems as JSR 14 under the Java Community Process (JCP). <o:p></o:p><br />Generics are one of the most frequently requested language extensions to Java, and they have been finally added in J2SE 5.0. This article provides an introduction to programming with generics.<br /><b>The Need for Generics<o:p></o:p></b><br />The motivation for adding generics to the Java programming language stems from the lack of information about a collection's element type, the need for developers to keep track of what type of elements collections contain, and the need for casts all over the place. Using generics, a collection is no longer treated as a list of <code><span style="font-size:10;">Object</span></code> references, but you would be able to differentiate between a collection of references to <code><span style="font-size:10;">Integer</span></code>s and collection of references to <code><span style="font-size:10;">Byte</span></code>s. A collection with a generic type has a type parameter that specifies the element type to be stored in the collection.<br /><br /><a style="color: rgb(102, 51, 255);" href="http://java.sun.com/developer/technicalArticles/J2SE/generics/"><i style="background-color: white;"><b>Click Here To Read More </b></i></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-50185737904839815272008-10-04T00:05:00.000-07:002008-10-04T01:40:35.270-07:00THE CONNECTED DEVICE CONFIGURATION AND THE FOUNDATION PROFILE<p>Much of what's been written about Java 2 Platform, Micro Edition (J2ME) talks about the Connected Limited Device Configuration, or CLDC for short. The CLDC defines an extremely small subset of the Java Platform for very limited devices -- devices, like cellular telephones, that do not have enough memory or enough processing power to handle a full-blown Java implementation. There is, however, another configuration available that is midway between the CLDC and a full Java 2 Platform, Standard Edition (J2SE) implementation: the Connected Device <span class="GramE">Profile,</span> or CDC for short. <o:p></o:p></p> The CDC defines a much less radical subset of J2SE. Unlike the CLDC, which is aimed at devices with less (often much less) than 512K bytes of total available memory, the CDC requires devices to have at least 2 megabytes of total memory available for Java. This can be a combination of read-only and read-write memory. The Java virtual machine (VM) and core class libraries are likely to be stored in read-only or flash memory.<br /><br /><a href="http://java.sun.com/developer/J2METechTips/2001/tt0529.html#tip1"><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-86653640947302681342008-10-03T23:58:00.000-07:002008-10-04T00:00:02.542-07:00Return-Type-Based Method Overloading in JavaIt is an accepted fact that Java does not support return-type-based method overloading. This means that a class cannot have two methods that differ only by return type -- you can't have <code>int doXyz(int x)</code> and <code>double doXyz(int x)</code> in the same class. And indeed, the Java compiler duly rejects any such attempt. But recently I discovered a way to do this, which I wish to share with all. Along the way, we will also explore some rudiments of Java bytecode programming<br /><br /><a href="http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html"><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-18836498180795483202008-10-03T23:51:00.000-07:002008-10-03T23:55:26.297-07:00An Introduction to the Lightweight User Interface Toolkit (LWUIT)Java ME allows us to write applications that are, generally speaking, portable across a wide range of small devices that support the platform. While the basic functionalities usually work well on all supported devices, the area that does pose problems for developers is the user interface. Native implementations of javax.microedition.lcdui -- the primary API for UIs in Java ME -- differ so widely from one device to another that maintaining a device independent and uniform look and feel is virtually impossible.<br />Non-uniform look and feel is not the only reason why developers have been waiting for something better to turn up. The javax.microedition.lcdui package does not support components and capabilities that can fully satisfy present-day user expectations.<br />It is in this context that the arrival of Lightweight User Interface Toolkit (LWUIT) is so exciting. LWUIT offers a wide range of widgets for building UIs. While some of these widgets are also available under lcdui, there are a number of new ones that enable application developers to design UIs that can come very close to their desktop counterparts in terms of visual sophistication. Even the components that are also offered by lcdui have been functionally enhanced. And LWUIT is not just about new components, either. The API supports a whole range of new functionalities, too -- theming, transitions, and more.prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-29681996536445298982008-10-03T23:45:00.000-07:002008-10-03T23:46:53.843-07:00Java Media Framework Player API<h3>Multimedia playback comes to Java! Learn how to start using audio and video in your applets and applications</h3><strong>What is the Java Media Framework?<br /><br /></strong>The JMF is a set of three new APIs being co-defined by the JMF Working Group members -- Sun, Silicon Graphics, and Intel. These APIs eventually will include Java Media Player, Capture, and Conferencing. The first to be delivered, the Player API provides a framework for implementors to build media players and provide them in a standard way on all Java platforms. The JMF specification is flexible enough to allow developers to extend players by adding their own nodes (such as images filters, audio reverb effects, and so on) or to use the standard players without making any additions.<br /><br /><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-88099539111868192282008-10-03T23:41:00.000-07:002008-10-03T23:42:12.209-07:00Painting in AWT and SwingIn a graphical system, a <i>windowing toolkit</i> is usually responsible for providing a framework to make it relatively painless for a graphical user interface (GUI) to render the <i>right</i> bits to the screen at the <i>right</i> time. <p>Both the AWT (abstract windowing toolkit) and Swing provide such a framework. But the APIs that implement it are not well understood by some developers -- a problem that has led to programs not performing as well as they could. </p> This article explains the AWT and Swing paint mechanisms in detail. Its purpose is to help developers write correct and efficient GUI painting code. While the article covers the general paint mechanism (<i>where</i> and <i>when</i> to render), it does not tell how to use Swing's graphics APIs to render a correct output<br /><a href="http://java.sun.com/products/jfc/tsc/articles/painting/"><br /><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-42519296972601828962008-10-03T23:35:00.000-07:002008-10-03T23:39:59.956-07:00Double Buffering and Page Flipping<span style="font-weight: bold;">Tips for reducing flicker while rendering images which moves </span><br /><br />Suppose you had to draw an entire picture on the screen, pixel by pixel or line by line. If you were to draw such a thing directly to the screen (using, say, <tt>Graphics.drawLine</tt>), you would probably notice with much disappointment that it takes a bit of time. You will probably even notice visible artifacts of how your picture is drawn. Rather than watching things being drawn in this fashion and at this pace, most programmers use a technique called <i>double-buffering</i>. <br /><a href="http://java.sun.com/docs/books/tutorial/extra/fullscreen/doublebuf.html"><br /><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-34211529740368126752008-10-03T23:27:00.000-07:002008-10-03T23:29:01.235-07:00Introduction to Java media programming<h3>Learn the basics of Java-based multimedia with the Java Media and Communication APIs</h3><span style="font-size:100%;">Java as a versatile programming language has gained widespread acceptance in the two-plus years since its introduction. It is widely espoused as having the usual benefits with which we are all familiar: cross-platform portability, a fairly secure runtime environment, strong networking and connectivity APIs, and so on.<br /><br /></span> <p><span style="font-size:100%;">However, no one could credibly argue that the Java platform as we know it (the 1.0 and 1.1 core platforms) is a multimedia power house. In fact, far from offering a robust set of multimedia APIs, Java as a platform still is adding a great many features and gaining acceptance. Media support is only now beginning to roll into the core platform (as part of the upcoming 1.2 release, which will include the Java 2D API and Java Sound engine). </span></p> <p><span style="font-size:100%;">These developments show promise for Java's media capabilities. In future installments of this column we'll be exploring the many aspects of this promise.<br /></span></p><p><span style="font-size:100%;"><a href="http://www.javaworld.com/jw-06-1998/jw-06-media.html"><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a><br /></span></p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-60968263607759119552008-10-03T23:12:00.000-07:002008-10-03T23:33:02.778-07:00Image processing with Java 2D<h3>Sophisticated image processing support comes to Java in the 2D API</h3><h1 style="font-family:times new roman;"><span style="font-size:100%;"><span style="font-weight: normal;font-size:100%;" >Image processing is the art and science of manipulating digital images. It stands with one foot firmly in mathematics and the other in aesthetics, and is a critical component of graphical computer systems. If you've ever bothered with creating your own images for Web pages, you will no doubt appreciate the importance of Photoshop's image manipulation capabilities for cleaning up scans and clearing up less-than-optimal images.</span><br /><br /></span> </h1><p><span style="font-size:85%;"><span style=";font-family:georgia;font-size:100%;" >If you did any image processing work in JDK 1.0 or 1.1, you probably remember that it was a little obtuse. The old model of image data producers and consumers is unwieldy for image processing. Before JDK 1.2, image processing involved <code>MemoryImageSource</code>s, <code>PixelGrabber</code>s, and other such arcana. Java 2D, however, provides a cleaner, easier to use model.</span><br /></span></p><p><span style="font-size:85%;"><a href="http://www.javaworld.com/javaworld/jw-09-1998/jw-09-media.html"><span style="font-weight: bold; font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a></span><br /></p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-17833440581508154062008-10-03T22:59:00.000-07:002008-10-03T23:31:22.371-07:00Saving bitmap files in Java<h3>A tutorial -- including all the code you need to write a bitmap file from an image object</h3><h1 style="font-weight: normal;font-family:times new roman;"><span style="font-size:100%;">A tutorial on how to save images in 24-bit bitmap files and a code snip you can use to write a bitmap file from an image object.</span></h1><span style="font-weight: bold;font-family:times new roman;font-size:100%;" ><a href="http://www.javaworld.com/javaworld/javatips/jw-javatip60.html"><span style="font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a></span>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-49171380518601433032008-10-03T09:42:00.000-07:002008-10-03T09:45:33.814-07:00Beginning J2ME: Building MIDlets<p class="first">MIDP (Mobile Information Device Profile) applications are piquantly called MIDlets, a continuation of the naming theme begun by applets and servlets. Writing MIDlets is relatively easy for a moderately experienced Java programmer. After all, the programming language is still Java. Furthermore, many of the fundamental APIs from <code>java.lang</code> and <code>java.io</code> are basically the same in the MIDP as they are in J2SE. Learning the new APIs (in the <code>javax.microedition</code> hierarchy) is not terribly difficult. </p> <p>The actual development process, however, is a little more complicated for MIDlets than it is for J2SE applications. Beyond a basic compile-and-run cycle, MIDlets require some additional tweaking and packaging. The complete build cycle goes like this: edit, source code, compile, preverify, package, test or deploy. </p> <p>To show how things work, and to give you a taste of MIDlet development, this article is dedicated to building and running a simple MIDlet. In this article, you'll get a feel for the big picture of MIDlet development.<br /></p><p><br /></p><p><a href="http://www.javaworld.com/javaworld/jw-05-2005/jw-0502-midlet.html"><span style="font-style: italic; font-weight: bold; color: rgb(102, 51, 255);">Click Here To Read More</span></a><br /></p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-87944557085355042952008-10-03T09:34:00.000-07:002008-10-03T09:35:54.067-07:00How to break a String into tokens with the StringTokenizer classWhen working with any general-purpose programming language, it's often necessary to break a large string into smaller components. Whether you're working with Unix system files, older Windows' ".ini" files, or maybe flat files in a text database, you'll often read in a record of information, and then break that record up into smaller chunks.<br /><br />In this article we'll demonstrate how to break Java <i><tt>String</tt></i>'s into smaller components, called <i>tokens</i>. We'll begin by breaking a simple well-known sentence into words, and then we'll demonstrate how to use the same technique to work with a flat-file database.<br /><a href="http://www.devdaily.com/java/edu/pj/pj010006/pj010006.shtml"><br /><span style="font-style: italic; font-weight: bold; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-75310791177059724802008-10-03T09:18:00.000-07:002008-10-03T09:19:42.554-07:00Random Numbers in JavaJava has a rich toolkit for generating random numbers, in a class named "Random". Random can generate many kinds of random number, not all of which I discuss here. <p>The best way to think of class Random is that its instances are random number generator objects -- objects that go around spitting out random numbers of various sorts in response to messages from their clients.</p><p><a href="http://www.cs.geneseo.edu/%7Ebaldwin/reference/random.html"><span style="font-style: italic; font-weight: bold; color: rgb(102, 51, 255);">Click Here To Read More</span></a><br /></p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-90512385641804435162008-10-03T07:31:00.000-07:002008-10-03T07:33:51.516-07:00How to make a JAVA application - executable JAR archiveSave all files from below into a directory. (rename *.java.txt to *.java)<br /> Create a batch file with the following content:<br /> <pre>javac DiveLog.java<br />jar cvfm DiveLog.jar mymanifest DiveLog.class DiveLog$1.class DiveLog$2.class Welcome.class</pre> <br /> Watch the line wrap: There are only 2 lines in the batch file, one starting with <span style="font-family:Courier New, Courier, mono;">javac</span> and the other with<span style="font-family:Courier New, Courier, mono;"> jar</span>.<br /> Run the batch file and it should compile the application and create DiveLog.jar, which can be clicked in order to run it.<br /> <br /> You can also run the application from the command line by typing: <pre>java -jar DiveLog.jar<br /></pre> which does the same like clicking on the icon of the application, but you can see any output written by System.out.println("..."); or error messages.<br /><br /><a href="http://www.captain.at/programming/java/executable-java-application.php"><span style="font-style: italic; color: rgb(102, 102, 204); font-weight: bold;">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com1tag:blogger.com,1999:blog-5599323567014703716.post-59310289160893663352008-10-03T07:15:00.000-07:002008-10-03T07:18:10.137-07:00Debugging with the Eclipse Platform<em>Use Eclipse for debugging your software projects<br /><br /></em>Find out how to use the built-in debugging features in the Eclipse Platform for debugging software projects. Debugging is something programmers can't avoid. There are many ways to go about it, but it essentially comes down to finding the code responsible for a bug. For example, one of the most common errors in Linux® applications is known as a <i>segmentation fault</i>. This occurs when a program attempts to access memory not allocated to it and terminates with a segmentation violation. To fix this kind of error, you need to find the line of code that triggers the behavior. Once the line of code in question has been found, it is also useful to know the context in which the error occurs, and the associated values, variables, and methods. The use of a debugger makes finding this information quite simple.<br /><br /><a href="http://www.ibm.com/developerworks/java/library/os-ecbug/"><span style="font-style: italic; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-250943290716241482008-10-03T06:34:00.000-07:002008-10-03T06:35:47.322-07:00What Is Performance?<blockquote>"More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason-including blind stupidity."</blockquote> <p align="right"><a name="17951"> </a> W. A. Wulf </p><a name="10875"></a> Before we can discuss how to improve performance, it's necessary to define what performance is. This isn't as simple as it sounds-people often mean very different things when they talk about performance. There are several aspects of performance, each of which contribute to the overall performance of an application. <p><a name="10876"> </a> Computers fascinate people with their ability to carry out tasks with blinding speed. When a computer, for whatever reason, doesn't perform a task quickly, users are disappointed. Developers often use the terms "speed" and "performance" interchangeably. However, to understand the different types of problems that can be encountered, all of the different aspects of performance must be considered: </p> <ul><a name="16356"></a><li>Computational performance <a name="16359"></a> </li><li>RAM footprint <a name="16360"></a> </li><li>Startup time <a name="16361"></a> </li><li>Scalability <a name="16362"></a> </li><li>Perceived performance </li></ul> <p><a name="16386"> </a>These factors lay the foundation for a better understanding of the performance landscape. Some aspects of performance are primarily applicable to client-side systems, some to server-side systems, and some to both. Understanding how each factor can contribute to the performance characteristics of a system will help you analyze the performance of your own applications.<br /></p><p><a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPPerformance.fm.html#15175"><span style="font-style: italic; font-weight: bold; color: rgb(102, 51, 255);">Click Here To Read More</span></a><br /></p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-37739477817767401882008-10-03T06:30:00.000-07:002008-10-03T06:32:27.579-07:00RAM FootprintA program that uses too much memory can force the operating system to rely on virtual memory. Because virtual memory is many times slower than physical RAM, relying on virtual memory can result in slow performance and a poor user experience. While developing your system, be aware of your target deployment environment and consider how much RAM will be available on machines running your software. <p><a name="17838"> </a> Before you can optimize your program's footprint, it's important to understand how memory is used. There are many common misconceptions about how memory is consumed by Java programs, and it is easy to put a lot of effort into footprint control for relatively small gains. By understanding the factors that contribute to footprint, you can make informed decisions when coding.<br /></p><p><br /></p><p><a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPRAMFootprint.fm.html#11396"><span style="font-style: italic; font-weight: bold; color: rgb(102, 51, 255);">Click Here To Read More</span></a><br /></p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-80595954172344087512008-10-03T06:18:00.000-07:002008-10-03T06:20:36.119-07:00Using MediaTracker to help load imagesWhen loading images over a network, a common problem which Java applets face is images not loading properly. On a fast network connection the image will load quickly, but over a slow modem or network connection, images take longer, or may not arrive at all. Users may be confused by blank images - particularly when a sequence of images are being displayed. One simple way to let your users know you're still loading is to use MediaTracker, which allows applets to detect when images are loaded.<br /><br /><a href="http://www.javacoffeebreak.com/articles/mediatracker/index.html"><span style="font-style: italic; font-weight: bold; color: rgb(102, 51, 255);">Click Here To Read More</span></a>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0tag:blogger.com,1999:blog-5599323567014703716.post-9945149293886322592008-10-03T06:14:00.000-07:002008-10-03T06:16:07.648-07:00Java vs C in speed performance<p align="left"><b>Fiction :<br /> </b><span style="color:#000080;">Java is a hundred times slower than C, so you shouldn't ever use it for "serious" programming.</span></p> <p align="left"><b>Fact :<br /> </b>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.</p> <p align="left">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.<br /></p>prasobhttp://www.blogger.com/profile/08173957717671742658noreply@blogger.com0