Don't I feel sheepish...
OK, so I've hacked this sample code below, from the ConfigurationPrinter
example in Hadoop: The Definitive Guide. If -libjars had been added to the
configuration I would expect to see it when I iterate over the urls, however
I see it as one of the remaining options:
***OUTPUT***
remaining args -libjars
remaining args C:\Apps\mahout-distribution-0.5\mahout-core-0.5.jar
***
[Source Code]
package test.option.demo;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.util.*;
// import java.util.*;
import java.net.URL;
// import java.util.Map.Entry;
public class OptionDemo extends Configured implements Tool{
static
{
Configuration.addDefaultResource("hdfs-default.xml");
Configuration.addDefaultResource("hdfs-site.xml");
Configuration.addDefaultResource("mapred-default.xml");
Configuration.addDefaultResource("mapred-site.xml");
}
@Override
public int run(String[] args) throws Exception
{
GenericOptionsParser opt = new GenericOptionsParser(args);
Configuration conf = opt.getConfiguration();
// for (Entry<String, String> entry: conf)
// {
// System.out.printf("%s=%s\n", entry.getKey(), entry.getValue());
// }
for (int i = 0; i < args.length;i++)
{
System.out.printf("remaining args %s\n", args[i]);
}
URL[] urls = GenericOptionsParser.getLibJars(conf);
if (urls != null)
{
for (int j = 0; j < urls.length;j++)
{
System.out.printf("url[%d] %s", j, urls[j].toString());
}else
System.out.println("No libraries added to configuration");
}
}
return 0;
}
public static void main(String[] args) throws Exception
{
int exitCode = ToolRunner.run(new OptionDemo(), args);
System.exit(exitCode);
}
}
On Mon, Aug 1, 2011 at 2:17 PM, John Armstrong <[email protected]>wrote:
> On Mon, 1 Aug 2011 13:21:27 -0400, "Aquil H. Abdullah"
> <[email protected]> wrote:
> > [AA] I am currently invoking my application as follows:
> >
> > hadoop jar /home/test/hadoop/test.option.demo.jar
> > test.option.demo.OptionDemo -libjar /home/test/hadoop/lib/mytestlib.jar
>
> I believe the problem might be that it's looking for "-libjars", not
> "-libjar".
>
--
Aquil H. Abdullah
[email protected]