SYS-CON Events announced today that Interface Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Interface Corporation is a company developing, manufacturing and marketing high quality and wide variety of industrial computers and interface modules such as PCIs and PCI express. For more information, visit http://www.i...| By Steve Beaty | Article Rating: |
|
| February 7, 2010 09:15 PM EST | Reads: |
28,750 |
Abstract
There are many different types of command line options that programs need to recognize. Many languages (e.g.: bash and perl) has built-in processing of command line options; Java does not. The Java Command Line Options (JCLO) package performs this task for a variety of option styles. It also uses Java's reflection capability to automatically assign values to variables in a specified class.
Introduction
Even in these days of sophisticated graphical user interfaces, many programs have a wide variety of command line options that help specify their behavior. It is also the case that command line only programs continue to enjoy wide use. It is also the case the command line arguments can become quite complicated, e.g.: -Djava.util.logging.config.file=All.finest -1 --list --this=that Some languages have built-in parsers for command line options; perl and bash are two obvious examples of this. Java has no such parser built in. The JCLO package provides the capability to parse several different command line option formats, and uses Java's reflecion mechanizm to both drive the parsing and assign the values provided by command line options to the variable in a specified class.
Brief overview of command line option formats
UNIX command line options started with a simple "dash and letter" format. "ls -l" is a classic example. If the option specified an additional option, the dash and letter were followed by a space and the additional option. "sort -t separator" is and example. UNIX also allowed the use of numbers, "ls -1", as options. As the number of possible option proliferated, and newer "GNU" style was developed. These have a "double dash/long name" style: "sort --version" for example. When additional options are needed for this style, it is typically provided with a "equals value" style: "gcc --std=c89". Finally, Java has its own style of "single dash/name with dots/equals value" style: "-Djava.util.logging.config.file=logging.props".
Specifying non-Java variable name options
JCLO uses Java reflection to extract variable names as the basis for parsing command line options. Not all styles just described are valid Java variable names and therefore JCLO uses several conventions to allow them specified. Java variables must begin with an alphabetic character or an underscore, numbers are not allowed to start a variable name. Variable names cannot contain dashes, as dashes specify subtraction or negation. They cannot contain dots as dots specify class references or decimal literals. Therefore, JCLO uses the convention of prefixing number options with an underscore (_1). For dashes embedded in options (e.g.: "--font-size=10"), JCLO uses two underscores ("font__size") in the variable name. For the embedded dots, JCLO uses a convention of an underscore followed by a dollar sign "_$".
Brief review of Java reflection
Java, as with other object oriented languages, has the ability to query and modify an object's internal information. One can retrieve a Class's constructors, methods, fields, etc. JCLO uses the getDeclaredFields()" method on a class to find the names it will accept and set the value for. One can either have a single class devoted to command line options or specify a prefix for the variables JCLO's will examine.
From class variables to command line options
First let's look at an example to see how JCLO works in practice. We have the obligatory import:
import edu.mscd.cs.jclo.JCLO;
and then we create a class whose class varibles will become the command line options:
class ExampleArgs
{
private int a;
private boolean b;
private float c;
private String d;
private String[] additional;
}
A simple main will be used to illustrate JCLO's operation:
public class Example
{
public static void main (String args[])
{
ExampleArgs ea = new ExampleArgs();
JCLO jclo = new JCLO (ea);
jclo.parse (args);
System.out.println ("a = " + ea.a);
System.out.println ("b = " + ea.b);
System.out.println ("c = " + ea.c);
System.out.println ("d = " + ea.d);
System.out.println ("additional = " +
java.util.Arrays.toString (ea.additional));
}
}
First, an object that contains the variables whose values will be assigned by the command line options is created. This object is then used to create a JCLO object. The parse method is then called with the command line options to do the actual work Running this simple program with the following command line options:
java -cp .:JCLO-1.3.4.jar Example -a 5 --b=true --c=9.0 -d Example one two three
produces:
a = 5 b = true c = 9.0 d = Example additional = [one, two, three]
Here, each of the class varibles where assigned values from the associated command line option. The additional String array is assigned any options beyond the last dash option. JCLO can also use only certain fields of an object by the programmer specifying a string prefix that those fields begin with.
There are times when command line options have aliases; for example a long and short version. JCLO has the ability to deal with these directly. Adding
String aliases[][] ={{"boolean", "b"}};
and modifying
JCLO jclo = new JCLO (ea, aliases);
to the above example allows for --boolean to set the value for b
:
java -cp .:JCLO-1.3.4.jar Example --boolean a = 0 b = true c = 0.0 d = null additional = null
JCLO also has a simple usage() method that returns a String of possible options and the type of values they require.
Conclusion
JCLO allows one to easily parse command line options and set the values inside a class based on those options. It is very flexible in its parsing, allowing intermixed single- and double-dashed options, along with aliases that allow long and short versions of an option. JCLO is available from http://jclo.sourceforge.net/.
Published February 7, 2010 Reads 28,750
Copyright © 2010 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Steve Beaty
Steve has an extensive background in both the theoretic and pragmatic aspects of computer science. He wrote compilers at Cray Computer, and both managed a large group of developers and was a software test architect at HP. He has a number of active open-source projects and is a professor of computer science at the Metropolitan State College of Denver.
SYS-CON Events announced today that Interface Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Interface Corporation is a company developing, manufacturing and marketing high quality and wide variety of industrial computers and interface modules such as PCIs and PCI express. For more information, visit http://www.i...Sep. 22, 2017 08:30 PM EDT Reads: 726 |
By Pat Romanski Sep. 22, 2017 08:30 PM EDT Reads: 795 |
By Elizabeth White In his session at @ThingsExpo, Greg Gorman is the Director, IoT Developer Ecosystem, Watson IoT, will provide a short tutorial on Node-RED, a Node.js-based programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using a wide range of nodes in the palette that can be deployed to its runtime in a single-click.
There is a large library of contributed nodes that help so...Sep. 22, 2017 06:30 PM EDT Reads: 663 |
By Elizabeth White What is the best strategy for selecting the right offshore company for your business?
In his session at 21st Cloud Expo, Alan Winters, U.S. Head of Business Development at MobiDev, will discuss the things to look for - positive and negative - in evaluating your options. He will also discuss how to maximize productivity with your offshore developers.
Before you start your search, clearly understand your business needs and how that impacts software choices.Sep. 22, 2017 06:30 PM EDT Reads: 428 |
By Liz McMillan SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...Sep. 22, 2017 05:30 PM EDT Reads: 707 |
By Liz McMillan While some developers care passionately about how data centers and clouds are architected, for most, it is only the end result that matters. To the majority of companies, technology exists to solve a business problem, and only delivers value when it is solving that problem. 2017 brings the mainstream adoption of containers for production workloads.
In his session at 21st Cloud Expo, Ben McCormack, VP of Operations at Evernote, will discuss how data centers of the future will be managed, how th...Sep. 22, 2017 04:45 PM EDT Reads: 1,199 |
By Pat Romanski There is huge complexity in implementing a successful digital business that requires efficient on-premise and cloud back-end infrastructure, IT and Internet of Things (IoT) data, analytics, Machine Learning, Artificial Intelligence (AI) and Digital Applications. In the data center alone, there are physical and virtual infrastructures, multiple operating systems, multiple applications and new and emerging business and technological paradigms such as cloud computing and XaaS. And then there are pe...Sep. 22, 2017 04:30 PM EDT Reads: 1,010 |
By Elizabeth White SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.Sep. 22, 2017 04:00 PM EDT Reads: 704 |
By Liz McMillan SYS-CON Events announced today that Keisoku Research Consultant Co. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Keisoku Research Consultant, Co. offers research and consulting in a wide range of civil engineering-related fields from information construction to preservation of cultural properties. For more information, vi...Sep. 22, 2017 03:45 PM EDT Reads: 705 |
By Yeshim Deniz SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...Sep. 22, 2017 03:00 PM EDT Reads: 2,373 |
By Pat Romanski SYS-CON Events announced today that Enroute Lab will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Enroute Lab is an industrial design, research and development company of unmanned robotic vehicle system. For more information, please visit http://elab.co.jp/. Sep. 22, 2017 02:30 PM EDT Reads: 810 |
By Liz McMillan SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...Sep. 22, 2017 02:00 PM EDT Reads: 690 |
By Elizabeth White Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets.
In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...Sep. 22, 2017 12:30 PM EDT Reads: 609 |
By Elizabeth White SYS-CON Events announced today that Fusic will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Fusic Co. provides mocks as virtual IoT devices. You can customize mocks, and get any amount of data at any time in your test. For more information, visit https://fusic.co.jp/english/. Sep. 22, 2017 12:00 PM EDT Reads: 810 |
By Pat Romanski Sep. 22, 2017 10:45 AM EDT Reads: 710 |
By Pat Romanski Sep. 22, 2017 10:00 AM EDT Reads: 774 |
By Elizabeth White Elon Musk is among the notable industry figures who worries about the power of AI to destroy rather than help society. Mark Zuckerberg, on the other hand, embraces all that is going on. AI is most powerful when deployed across the vast networks being built for Internets of Things in the manufacturing, transportation and logistics, retail, healthcare, government and other sectors. Is AI transforming IoT for the good or the bad? Do we need to worry about its potential destructive power? Or will we...Sep. 22, 2017 09:15 AM EDT Reads: 951 |
By Elizabeth White Sep. 22, 2017 09:00 AM EDT Reads: 774 |
By Elizabeth White Sep. 22, 2017 09:00 AM EDT Reads: 1,291 |
By Elizabeth White SYS-CON Events announced today that Nihon Micron will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Nihon Micron Co., Ltd. strives for technological innovation to establish high-density, high-precision processing technology for providing printed circuit board and metal mount RFID tags used for communication devices. For more inf...Sep. 22, 2017 08:00 AM EDT Reads: 750 |

In his session at @ThingsExpo, Greg Gorman is the Director, IoT Developer Ecosystem, Watson IoT, will provide a short tutorial on Node-RED, a Node.js-based programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using a wide range of nodes in the palette that can be deployed to its runtime in a single-click.
There is a large library of contributed nodes that help so...
What is the best strategy for selecting the right offshore company for your business?
In his session at 21st Cloud Expo, Alan Winters, U.S. Head of Business Development at MobiDev, will discuss the things to look for - positive and negative - in evaluating your options. He will also discuss how to maximize productivity with your offshore developers.
Before you start your search, clearly understand your business needs and how that impacts software choices.
SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...
While some developers care passionately about how data centers and clouds are architected, for most, it is only the end result that matters. To the majority of companies, technology exists to solve a business problem, and only delivers value when it is solving that problem. 2017 brings the mainstream adoption of containers for production workloads.
In his session at 21st Cloud Expo, Ben McCormack, VP of Operations at Evernote, will discuss how data centers of the future will be managed, how th...
There is huge complexity in implementing a successful digital business that requires efficient on-premise and cloud back-end infrastructure, IT and Internet of Things (IoT) data, analytics, Machine Learning, Artificial Intelligence (AI) and Digital Applications. In the data center alone, there are physical and virtual infrastructures, multiple operating systems, multiple applications and new and emerging business and technological paradigms such as cloud computing and XaaS. And then there are pe...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that Keisoku Research Consultant Co. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Keisoku Research Consultant, Co. offers research and consulting in a wide range of civil engineering-related fields from information construction to preservation of cultural properties. For more information, vi...
SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
SYS-CON Events announced today that Enroute Lab will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Enroute Lab is an industrial design, research and development company of unmanned robotic vehicle system. For more information, please visit http://elab.co.jp/.
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets.
In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...
SYS-CON Events announced today that Fusic will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Fusic Co. provides mocks as virtual IoT devices. You can customize mocks, and get any amount of data at any time in your test. For more information, visit https://fusic.co.jp/english/.
Elon Musk is among the notable industry figures who worries about the power of AI to destroy rather than help society. Mark Zuckerberg, on the other hand, embraces all that is going on. AI is most powerful when deployed across the vast networks being built for Internets of Things in the manufacturing, transportation and logistics, retail, healthcare, government and other sectors. Is AI transforming IoT for the good or the bad? Do we need to worry about its potential destructive power? Or will we...
SYS-CON Events announced today that Nihon Micron will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Nihon Micron Co., Ltd. strives for technological innovation to establish high-density, high-precision processing technology for providing printed circuit board and metal mount RFID tags used for communication devices. For more inf...
Containers are the future of web development, in large part thanks to Docker’s explosive growth. According to DataDog, 15 percent of hosts run Docker, which is significantly up from the 6 percent of hosts running it at this point in 2015. LinkedIn has also seen a 160 percent increase in profile references to Docker in just the past year alone, indicating Docker has become a much bigger priority for IT professionals looking for work. With this technology primed to continue its exponential growth ...
DevOps at Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world.
The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to w...
New competitors, disruptive technologies, and growing expectations are pushing every business to both adopt and deliver new digital services. This ‘Digital Transformation’ demands rapid delivery and continuous iteration of new competitive services via multiple channels, which in turn demands new service delivery techniques – including DevOps. In this power panel at @DevOpsSummit 20th Cloud Expo, moderated by DevOps Conference Co-Chair Andi Mann, panelists examined how DevOps helps to meet the de...
Cloud Expo, Inc. has announced today that Andi Mann and Aruna Ravichandran have been named Co-Chairs of @DevOpsSummit at Cloud Expo Silicon Valley which will take place Oct. 31-Nov. 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. "DevOps is at the intersection of technology and business-optimizing tools, organizations and processes to bring measurable improvements in productivity and profitability," said Aruna Ravichandran, vice president, DevOps product and solutions marketing...
Not very long ago, in my IT consulting career, I used to be responsible for the launch of mission-critical applications that help enterprises leap into the cutting edge of the digital business revolution. There were a lot of hard skills required for leading such a mission that involved getting the system architecture and software design right early, mentoring and managing the engineering resources, and tracking the progress to the satisfaction of the business analysts who put together the requir...
‘Trend’ is a pretty common business term, but its definition tends to vary by industry. In performance monitoring, trend, or trend shift, is a key metric that is used to indicate change.
Change is inevitable. Today’s websites must frequently update and change to keep up with competition and attract new users, but such changes can have a negative impact on the user experience if not managed properly. The dynamic nature of the Internet makes it necessary to constantly monitor different metrics. O...
SYS-CON Events announced today that DXWorldExpo has been named “Global Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Digital Transformation is the key issue driving the global enterprise IT business. Digital Transformation is most prominent among Global 2000 enterprises and government institutions.
One of the biggest challenges with adopting a DevOps mentality is: new applications are easily adapted to cloud-native, microservice-based, or containerized architectures - they can be built for them - but old applications need complex refactoring. On the other hand, these new technologies can require relearning or adapting new, oftentimes more complex, methodologies and tools to be ready for production.
In his general session at @DevOpsSummit at 20th Cloud Expo, Chris Brown, Solutions Marketi...
In the world of DevOps there are ‘known good practices’ – aka ‘patterns’ – and ‘known bad practices’ – aka ‘anti-patterns.' Many of these patterns and anti-patterns have been developed from real world experience, especially by the early adopters of DevOps theory; but many are more feasible in theory than in practice, especially for more recent entrants to the DevOps scene. In this power panel at @DevOpsSummit at 18th Cloud Expo, moderated by DevOps Conference Chair Andi Mann, panelists discussed...
Everyone could agree that silos created unnecessary separation, protectionism, and bureaucracy. No one would dare argue that having rigid silos were somehow good for the organization.
Silos were, therefore, the easy target. They became the mantle onto which leaders could lay all past transgressions, and, in so doing, they became a convenient artifice to allow the leader to proclaim the dawn of a new era of integration, collaboration, and communication.
Silos are dead!
Except they never quite...
Over the last several months, intent-based networking (IBNS) has gained momentum as a newly viable technology that aims to further automate traditional network management. Although IBNS has existed for a few years now as a general concept, it was more buzz than reality until Cisco® launched its first IBNS software package earlier this year.
What is intent-based networking?
Traditionally, network administrators manually translate business policies into network device configurations, a time-int...
DevOps is being widely accepted (if not fully adopted) as essential in enterprise IT. But as Enterprise DevOps gains maturity, expands scope, and increases velocity, the need for data-driven decisions across teams becomes more acute. DevOps teams in any modern business must wrangle the ‘digital exhaust’ from the delivery toolchain, "pervasive" and "cognitive" computing, APIs and services, mobile devices and applications, the Internet of Things, and now even blockchain.
DevOps at Cloud Expo – being held October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real r...
























