<?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>SolitaryGeek &#187; tools</title>
	<atom:link href="http://solitarygeek.com/tag/tools/feed" rel="self" type="application/rss+xml" />
	<link>http://solitarygeek.com</link>
	<description>James Selvakumar&#039;s Blog</description>
	<lastBuildDate>Tue, 21 Dec 2010 04:35:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Developing A Simple Pluggable Java Application</title>
		<link>http://solitarygeek.com/java/a-simple-pluggable-java-application</link>
		<comments>http://solitarygeek.com/java/a-simple-pluggable-java-application#comments</comments>
		<pubDate>Sun, 20 Sep 2009 15:23:12 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[pluggable]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/java/a-simple-pluggable-java-application/</guid>
		<description><![CDATA[<p>Most of the applications we use on daily basis are pluggable. Popular applications like Firefox, Eclipse, NetBeans, JEdit, WordPress, Hudson are all pluggable. In fact, pluggability has played a major part in the success of most of these applications. Why not make the Java applications we develop pluggable as well? Yes, we get pluggability out of the box, if our applications are based on a rich client platform like NetBeans or Eclipse. But for some reasons if you decide not to use those platforms, it doesn&#8217;t mean that they should not be pluggable. In this article, we will learn how <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/a-simple-pluggable-java-application">Developing A Simple Pluggable Java Application</a></span>]]></description>
			<content:encoded><![CDATA[<p>Most of the applications we use on daily basis are pluggable. Popular applications like Firefox, Eclipse, NetBeans, JEdit, WordPress, Hudson are all pluggable. In fact, pluggability has played a major part in the success of most of these applications. Why not make the Java applications we develop pluggable as well? Yes, we get pluggability out of the box, if our applications are based on a rich client platform like NetBeans or Eclipse. But for some reasons if you decide not to use those platforms, it doesn&#8217;t mean that they should not be pluggable. In this article, we will learn how to write a simple pluggable application that will load it&#8217;s plugins dynamically.</p>
<p><strong>The API<br />
</strong>First, let us define a plugin interface that should be implemented by all the plugins of our application. We are going to keep it very simple. Create a project called &#8220;plugin-api&#8221; in your favorite IDE and create the interface &#8220;ApplicationPlugin&#8221;.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot1-p2.png" alt="" /></p>
<pre class="brush: java; title: ; notranslate">

package com.pluggableapp.plugins.api;

public interface ApplicationPlugin
{
    String getName();
    void init();
}
</pre>
<p><span id="more-464"></span></p>
<p><strong>The Plugins</strong></p>
<p>Writing the plugins now is very easy. Our plugins need to implement the plugin interface and follow a simple convention to make it easy for our applications to find them later. Create a project called &#8220;plugin-a&#8221; and develop our first plugin.</p>
<pre class="brush: java; title: ; notranslate">

package com.pluggableapp.plugins;

import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.logging.Logger;

public class PluginA implements ApplicationPlugin
{
    private static Logger logger = Logger.getLogger(PluginA.class.getName());

    public String getName()
    {
        return &quot;Plugin A&quot;;
    }

    public void init()
    {
        logger.info(getName() + &quot; initialized!&quot;);
    }
}
</pre>
<p>Now create a directory called &#8220;META-INF/services&#8221; inside the source directory and create a file with the name &#8220;com.pluggableapp.plugins.api.ApplicationPlugin&#8221; (This is the fully qualified name of the plugin interface). The file should contain the name of the actual plugin inside it. In our case, the text is &#8220;com.pluggableapp.plugins.PluginA&#8221;.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot4-p.png" alt="" /></p>
<p>Repeat these steps to create PluginB.</p>

<p><strong>The Application</strong></p>
<p>It&#8217;s time to create the application that will consume the plugins we created. First let us create a class to add the plugin jars to the classpath dynamically.</p>
<pre class="brush: java; title: ; notranslate">

package com.pluggableapp;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.logging.Logger;

public class ClasspathUtils
{

 private static Logger logger = Logger.getLogger(ClasspathUtils.class.getName());
 // Parameters
 private static final Class[] parameters = new Class[]
 {
     URL.class
 };

 /**
 * Adds the jars in the given directory to classpath
 * @param directory
 * @throws IOException
 */
 public static void addDirToClasspath(File directory) throws IOException
 {
     if (directory.exists())
     {
         File[] files = directory.listFiles();
         for (int i = 0; i &lt; files.length; i++)
         {
             File file = files[i];
             addURL(file.toURI().toURL());
         }
     }
     else
     {
         logger.warning(&quot;The directory \&quot;&quot; + directory + &quot;\&quot; does not exist!&quot;);
     }
}

 /**
 * Add URL to CLASSPATH
 * @param u URL
 * @throws IOException IOException
 */
 public static void addURL(URL u) throws IOException
 {
     URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
     URL urls[] = sysLoader.getURLs();
     for (int i = 0; i &lt; urls.length; i++)
     {
         if (urls[i].toString().equalsIgnoreCase(u.toString()))
         {
             logger.info(&quot;URL &quot; + u + &quot; is already in the CLASSPATH&quot;);
             return;
         }
     }
     Class sysclass = URLClassLoader.class;
     try
     {
         Method method = sysclass.getDeclaredMethod(&quot;addURL&quot;, parameters);
         method.setAccessible(true);
         method.invoke(sysLoader, new Object[]
         {
             u
         });
     } catch (Throwable t)
     {
         t.printStackTrace();
         throw new IOException(&quot;Error, could not add URL to system classloader&quot;);
     }
  }
}
</pre>
<p>Now create an interface called &#8220;PluginService&#8221; to define the methods needed to load and initialize the plugins.</p>
<pre class="brush: java; title: ; notranslate">

package com.pluggableapp;

import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.Iterator;

public interface PluginService
{
    Iterator&lt;ApplicationPlugin&gt; getPlugins();
    void initPlugins();
}
</pre>
<p>As of version 1.6, the Java runtime ships with a class called &#8220;ServiceLoader&#8221; to easily find and load plugins. Let us now write a implementation called &#8220;StandardPluginService&#8221; and make use of the facilities built into the java runtime.</p>
<pre class="brush: java; title: ; notranslate">

package com.pluggableapp;

import com.pluggableapp.PluginService;
import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.Iterator;
import java.util.ServiceLoader;
import java.util.logging.Logger;

public class StandardPluginService implements PluginService
{
    private static StandardPluginService pluginService;
    private ServiceLoader&lt;ApplicationPlugin&gt; serviceLoader;
    private Logger logger = Logger.getLogger(getClass().getName());

    private StandardPluginService()
    {
        //load all the classes in the classpath that have implemented the interface
        serviceLoader = ServiceLoader.load(ApplicationPlugin.class);
    }

    public static StandardPluginService getInstance()
    {
        if(pluginService == null)
        {
            pluginService = new StandardPluginService();
        }
        return pluginService;
    }

    public Iterator&lt;ApplicationPlugin&gt; getPlugins()
    {
        return serviceLoader.iterator();
    }

    public void initPlugins()
    {
        Iterator&lt;ApplicationPlugin&gt; iterator = getPlugins();
        if(!iterator.hasNext())
        {
            logger.info(&quot;No plugins were found!&quot;);
        }
        while(iterator.hasNext())
        {
            ApplicationPlugin plugin = iterator.next();
            logger.info(&quot;Initializing the plugin &quot; + plugin.getName());
            plugin.init();
        }
    }
}
</pre>
<p>Feel free to write your own implementation if needed. For example you can easily write an implementation based on the NetBeans API.</p>
<p>Write a factory class named &#8220;PluginServiceFactory&#8221; to create &#8220;PluginService&#8221; objects.</p>
<pre class="brush: java; title: ; notranslate">

package com.pluggableapp;

import com.pluggableapp.*;
import com.pluggableapp.StandardPluginService;
import com.pluggableapp.PluginService;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class PluginServiceFactory
{
    public static PluginService createPluginService()
    {
        addPluginJarsToClasspath();
        return StandardPluginService.getInstance();
    }

    private static void addPluginJarsToClasspath()
    {
        try
        {
            //add the plugin directory to classpath
            ClasspathUtils.addDirToClasspath(new File(&quot;plugins&quot;));
        } catch (IOException ex)
        {
            Logger.getLogger(PluginServiceFactory.class.getName()).log(
                Level.SEVERE, null, ex);
        }
    }
}
</pre>
<p>That&#8217;s it. All we need to do now is to write a class that will invoke the &#8220;PluginServiceFactory&#8221;.</p>
<pre class="brush: java; title: ; notranslate">

package com.pluggableapp;

import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.Iterator;
import java.util.logging.Logger;

public class Main
{

    private static Logger logger = Logger.getLogger(Main.class.getName());

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args)
    {
        loadPlugins();
    }

    private static void loadPlugins()
    {
        PluginService pluginService = PluginServiceFactory.createPluginService();
        pluginService.initPlugins();
    }
}
</pre>
<p>Before we build and see the application in action, create a directory called &#8220;plugins&#8221; and put all plugin jars there.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot3-p1.png" alt="" /></p>
<p>And this is what you might see when you run our pluggable application.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot2-p1.png" alt="" /></p>
<p>Now feel free to create as many plugins you want to write and just drop them in the &#8220;plugins&#8221; directory and restart the &#8220;pluggable&#8221; application to see your &#8220;home grown&#8221; plugins in action!</p>
<p><strong>Resources</strong></p>
<p><a href="http://java.sun.com/developer/technicalArticles/javase/extensible/index.html">Creating Extensible Applications With the Java Platform</a> &#8211; <em>John O&#8217;Conner</em></p>
<p><a href="http://twit88.com/blog/2007/10/07/develop-a-java-plugin-framework/">Developing a Java Plugin Framework </a></p>
<p><a href="http://java.dzone.com/news/how-create-pluggable-photo-alb">How to Create a Pluggable Photo Album in Java</a> &#8211; <em>Geertjan</em></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=d7d85c06-7c20-8a72-ae33-ec6bc5f32317" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/a-simple-pluggable-java-application/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Five different uses of Java Applets</title>
		<link>http://solitarygeek.com/java/five-different-uses-of-java-applets</link>
		<comments>http://solitarygeek.com/java/five-different-uses-of-java-applets#comments</comments>
		<pubDate>Sat, 22 Aug 2009 09:54:42 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[applets]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/java/java-technology-tech-computers-software-applications-tools-applets/</guid>
		<description><![CDATA[<p>In a world where everyone is using technologies like Flash, Silverlight etc to present rich content, are Java Applets still used? Are they still relevant? The answer is &#8211; &#8220;Yes&#8221;. Apart from being used primarily for playing online games, Java Applets are still used in many different ways. Here I would like to highlight a few applications that put Applets to good use.</p> <p>1. Online Office Suite ThinkFree is a very popular and professional online office suite based on Java Applet and Ajax.</p> <p></p> <p>2. Virtualization JPC or Java PC Emulator is a pure java based virtualization software that can <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/five-different-uses-of-java-applets">Five different uses of Java Applets</a></span>]]></description>
			<content:encoded><![CDATA[<p>In a world where everyone is using technologies like Flash, Silverlight etc to present rich content, are Java Applets still used? Are they still relevant? The answer is &#8211; &#8220;Yes&#8221;. Apart from being used primarily for playing online games, Java Applets are still used in many different ways. Here I would like to highlight a few applications that put Applets to good use.</p>
<p><strong>1. Online Office Suite</strong><br />
<a href="http://thinkfree.com">ThinkFree</a> is a very popular and professional online office suite <a href="http://en.wikipedia.org/wiki/ThinkFree_Office">based on Java Applet and Ajax</a>.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/08/screenshot2-p1.png" alt="" /></p>
<p><strong>2. Virtualization</strong><br />
<a href="http://www-jpc.physics.ox.ac.uk/home_home.html">JPC</a> or <a href="http://www-jpc.physics.ox.ac.uk/home_home.html">Java PC Emulator</a> is a pure java based virtualization software that can be used to boot your virtual computers right inside the browser. Yes they run as &#8220;Java Applets&#8221; inside the browser.</p>
<p><strong>3. Remote Desktop Viewer</strong><br />
Products like <a href="http://www.tightvnc.com/">TightVNC</a> and <a href="http://www.uvnc.com/">UltraVNC</a> provide a java applet based client to view remote desktops.</p>
<p><strong>4. (Web) Operating System<br />
</strong><a href="http://icloud.com">iCloud</a>, is an web operating sytem that makes use of XML and Java Applet Technology (atleast for Firefox).</p>
<p><strong>5. File Upload</strong></p>
<p><a href="http://www.facebook.com">Facebook</a> uses a beautifully designed Java Applet to upload photos to facebook photo albums.<br />
<a href="http://net2ftp.com">net2ftp</a> is a web based ftp client that makes use of tiny Java Applet to &#8220;drag and drop&#8221; files from local computer to the browser and upload them to the remote ftp server.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/08/screenshot1-p.png" alt="" /></p>
<p>If you have come across any website that make use of Java Applets, please share your thoughts in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/five-different-uses-of-java-applets/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Must have tools for a Java Developer</title>
		<link>http://solitarygeek.com/java/must-have-tools-for-a-java-developer</link>
		<comments>http://solitarygeek.com/java/must-have-tools-for-a-java-developer#comments</comments>
		<pubDate>Wed, 19 Mar 2008 07:54:20 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://jamesselvakumar.wordpress.com/?p=48</guid>
		<description><![CDATA[<p>Apart from your favourite IDE, I feel, a Java Developer might be very productive with the following tools (in no particular order):</p> <p>- Firefox (Do I need to say anything about it?)</p> <p>- Apache Ant (Not needed, if you use NetBeans. NetBeans has got bundled ant)</p> <p>- JEdit (Mainly for it&#8217;s wide range of plugins. I use it&#8217;s LogViewer and HexViewer plugin frequently. Also it has got excellent syntax highlighting for your properties file, java files, nsis scripts etc)</p> <p>- Subversion Version Control System(Got excellent integration with NetBeans and Eclipse. You must consider it atleast for your personal development.) You <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/must-have-tools-for-a-java-developer">Must have tools for a Java Developer</a></span>]]></description>
			<content:encoded><![CDATA[<p>Apart from your favourite IDE, I feel, a Java Developer might be very productive with the following tools (in no particular order):</p>
<p>- <a href="http://www.mozilla.com/en-US/firefox/"><b>Firefox</b></a> (Do I need to say anything about it?)</p>
<p>- <a href="http://ant.apache.org/"><b>Apache Ant</b></a> (Not needed, if you use NetBeans. NetBeans has got bundled ant)</p>
<p>-  <a href="http://www.jedit.org/"><b>JEdit</b></a> (Mainly for it&#8217;s wide range of plugins. I use it&#8217;s LogViewer and HexViewer plugin frequently. Also it has got excellent syntax highlighting for your properties file, java files, nsis scripts etc)</p>
<p>- <b><a href="http://subversion.tigris.org/">Subversion</a> </b>Version Control System(Got excellent integration with NetBeans and Eclipse. You must consider it atleast for your personal development.) You can read more about installing subversion <a href="http://jamesselvakumar.wordpress.com/2008/03/14/extending-subversion-by-using-tortoisesvn/">here</a>.</p>
<p><span id="more-185"></span>- <a href="http://tomcat.apache.org/"><b>Apache Tomcat</b></a> (The ubiquitous servlet container.)</p>
<p>- <a href="https://glassfish.dev.java.net//"> <b>Glassfish</b></a> (The best open source application server, at the moment. Thanks RedHat for making JBoss AS development sluggish. JBoss AS users are waiting for nearly 1 1/2 years for the 5.0 release.)</p>
<p>- <a href="https://hudson.dev.java.net/"><b>Hudson</b></a> (The fastest growing continuous integration server. This can be an excellent add-on to your ant/maven based build process). You can read more about hudson <a href="http://jamesselvakumar.wordpress.com/2008/03/07/continuous-integration-with-hudson/">here</a>.</p>
<p>-  <a href="http://wrapper.tanukisoftware.org/doc/english/introduction.html"><b>Java Service Wrapper</b></a> (An excellent product to launch your java applications as a windows service)</p>
<p>- <b><a href="http://checkstyle.sourceforge.net/">CheckStyle</a>/<a href="http://pmd.sourceforge.net/">PMD</a></b> (Excellent code coverage tools to make your source code more maintainable)</p>
<p>- <a href="http://www.jasypt.org/"><b>JASYPT</b></a> (Excellent cryptography library to encrypt/decrypt your passwords, files etc.)</p>
<p>- <b><a href="http://commons.apache.org/">Apache Commons Library</a></b> (Contains almost all the utility classes you will ever need. Kindly check this project before writing your own utility classes)</p>
<p>- <b><a href="http://jude.change-vision.com/jude-web/product/community.html">JUDE Community</a></b> (An excellent free UML modelling tool. You must definitely give it a try. It&#8217;s lightweight and it&#8217;s very simple to use.)</p>
<p>- <b><a href="http://www.mysql.com/">MySQL</a></b> (The most popular open source database at the moment)</p>
<p>Did anybody say that I forgot to add <a href="http://www.google.com"><b>Google</b></a> as well <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>What else do you use? It will be of great use to the community if you can share about your experience as well.</p>
<p><i>Note:</i> I tend not to include frameworks like Spring, JSF, Wicket etc.. Because you can see these frameworks too are highly subjective and a major reason for lots of flamewars. And that&#8217;s the reason why I didn&#8217;t mention any IDE as well. Whatever IDE or framework you use, it&#8217;s very likely that you might need the above mentioned &#8220;tools&#8221; except a few like database/application server, whose choice are mostly defined by a particular organization.</p>
<p>You should read this article in the perspective of &#8220;tools needed for your personal java development&#8221;. Because there are &#8220;lots&#8221; of factors involved in your work environment regarding the selection of tools.</p>
<p>And lastly, this is my humble suggestion only. So if you find your favourite tool missing, don&#8217;t get panic. Cheers&#8230; <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/must-have-tools-for-a-java-developer/feed</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

