I wrote a simple code to test how to set configuration in Hadoop.
public static void main(String[] args) {
Configuration conf = new Configuration();
conf.addResource("~/conf.xml");
System.out.println(conf);
System.out.println(conf.get("color"));
}
The output of above program is:
Configuration: core-default.xml, core-site.xml, ~/conf.xml
null
Thus conf.get("color")
returns null
. However, I have explicitly set that property in conf.xml
as follows:
<property>
<name>color</name>
<value>yellow</value>
<description>Color</description>
</property>
The resource needs to be added as a URL, otherwise the String is interpreted as a classpath resource (which at the moment does not resolve and is ignored - i know you you think that a warn message would be dumped somewhere):
Anyway, try this (i get yellow in the syserr):