I want to pass the location of hive-site.xml file in my java program.
What is the best way to find out the location of this file automatically in java code?
I do not want to hard code the path to /etc/hive/conf/hive-site.xml
for cloudera distibution
By default the Hadoop
Configuration
constructors search for "blahblah-site.xml" config files in directories present in CLASSPATH. If it doesn't find them, then it reverts to hard-coded "default" values, without any warning (!).So make sure that the CLASSPATH contains the appropriate directories on the front, e.g.
/etc/hadoop/conf/:/etc/hive/conf/:/etc/tez/conf/:...
Then the only thing you have to do in your Java code is to check that critical properties are set up with something else that hard-coded defaults (and raise a PleaseSetupProperClasspathYouSuckerException if it's not the case).
String path = System.getenv("HIVE_HOME");