commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Courtenage <courten...@gmail.com>
Subject [EXEC] Problems with command-line arguments when starting Java process
Date Wed, 11 May 2011 09:54:25 GMT
Hi,

I'm using the Commons Exec library to write a class that starts up a number
of processes that run another Java class.  The code run
by each of these processes then act as peers in a P2P network. My code for
starting these processes, in brief, looks like this:

                CommandLine cmd = new CommandLine("java");
                cmd.addArgument("-classpath");
                cmd.addArgument(classpath);
                cmd.addArgument("uk.ac.wmin.
fel.BrokerMain");
                cmd.addArgument("\"-host\"");
                cmd.addArgument(thisnode.getHost());
                cmd.addArgument("\"-port\"");
                cmd.addArgument(Integer.toString(thisnode.getPort()));
                cmd.addArgument("\"-id\"");
                cmd.addArgument(Integer.toString(thisnode.getID()));
                DefaultExecuteResultHandler rhandler = new
DefaultExecuteResultHandler();
                ExecuteWatchdog wdog = new ExecuteWatchdog(5000);
                Executor executor = new DefaultExecutor();
                executor.setWatchdog(wdog);
                executor.execute(cmd, rhandler);

where thisnode is an object that holds data about the hostname and port that
the BrokerMain class will use to act as a server process.
However, when I try to execute this, I get the following error:

                Could not create the Java virtual machine.
                Unrecognized option: -host

Can anyone help?  It seems that the command line argument to the BrokerMain
class is being seen as an argument to the Java interpreter, but I
don't know how to overcome this problem.

Thanks for any help,

Simon

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message