swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Java Arguments to swarm programs


From: Paul E Johnson
Subject: Java Arguments to swarm programs
Date: Tue, 19 Jun 2001 15:43:54 -0500

We were fussing about command line arguments to swarm programs and I was
complaining that it is too complicated to do this in java.  In a private
email, Marcus Daniels pointed out that it is as easy as using
System.getProperty() to retrieve a command line argument.  I felt like
the old TV commercial slogan: I could have had a V8! (or was it "Now
that's a spicy meatball").  I'm so totally disgusted I stopped reading
Core Java on p. 699, because this option is described on p. 700 :)

So put this in a java swarm program.  Put it anywhere:

        String Dinput= System.getProperty("Whatever");
        System.out.println ("Whatever is set to " + Dinput);

I stuck that into TestPixmap.java, just cause it was lying around.

Compile, and run  

$ javaswarm -DWhatever=phil TestPixmap
Whatever is set to phil

You can pass through anything you want to a java program this way.  ONce
you have the string, you can of course parse it anyway you want.  FOr
example, you can pass through a variable name and a value, as in:

$ javaswarm -DWhatever=phil=999 TestPixmap
Whatever is set to phil=999

Or more than one parameter in string form:

$ javaswarm -DWhatever="phil=999 james=234" TestPixmap
Whatever is set to phil=999 james=234


 Or you can add separate options and observe. Here I put in the java
program:

 System.out.println ("Other is set to " + System.getProperty("Other"));

$ javaswarm -DWhatever=phil -DOther=2343  TestPixmap
Whatever is set to phil
Other is set to 2343

So, all in all, I'm delighted, happy, relieved, aggravated, and
nonplussed all at the same time.  Kinda like the first time I saw Basic
Instinct.

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]