Quite early in every NetBeans Platform Certified Training, students are told: "But there's no law saying your NetBeans Platform application must have a desktop GUI. In fact, it could be the basis of a command line tool, which would have no GUI, or a web application, which would have a web frontend."
Jaroslav Tulach's "DVB Central" is one example of a modular command line tool. Today, I created another one. With my command line tool, you can type this on the command line:
shparser --speech "my kingdom for a horse"
And then the command line will show you the speech in Shakespeare where this phrase comes from:

I used the web service client development tools in the IDE to generate a lot of the code needed for the above; this is all the code I typed myself:import java.util.Collections;import java.util.Map;import java.util.Set;import org.netbeans.api.sendopts.CommandException;import org.netbeans.spi.sendopts.Env;import org.netbeans.spi.sendopts.Option;import org.netbeans.spi.sendopts.OptionProcessor;import org.openide.LifecycleManager;import org.openide.util.lookup.ServiceProvider;@ServicePr ovider(service = OptionProcessor.class)public class SCLProcessor extends OptionProcessor { private Option speech = Option.requiredArgument('s', "speech"); @Override protected Set getOptions() { return Collections.singleton(speech); } @Override protected void process(Env env, Map values) throws CommandException { String[] args = (String[]) values.get(speech); if (args.length > 0) { try { java.lang.String request = args[0]; shakespeare.Shakespeare service = new shakespeare.Shakespeare(); shakespeare.ShakespeareSoap port = service.getShakespeareSoap(); java.lang.String result = port.getSpeech(request); System.out.println(result); LifecycleManager.getDefault().exit(); } catch (Exception ex) { ex.printStackTrace(); } } }}
I included the above in a module, which is part of an application that has a very minimal set of NetBeans Platform modules. In addition to the runtime container, there are only modules for providing the web service functionality.
I added "--nosplash" to "default_options" in the configuration file and now no splash screen is shown when the application starts up. I must say, performance is really good. Sure, I need to be online in order to be able to access my Shakespeare web service, but that's the only constraint. For this kind of application, where you need some quick data based on a simply query, the command line is really perfect.
Plus, of course, the application is modular. New features can be delivered, though they'd need to be installed manually, in the absence of a GUI (i.e., no Plugin Manager). Or maybe updates could be pushed silently to the end users of my command line tool.


Read More about [Modular Command Line Tool...