Hey, @Amey,
This is probably because of a lack of configuration. Try to add the Hadoop configuration files as a resource to the object Configuration:
Configuration conf = new Configuration();
conf.addResource(new Path("/etc/hadoop/conf/core-site.xml"));
conf.addResource(new Path("/etc/hadoop/conf/hdfs-site.xml"));
FileSystem hdfs = FileSystem.get(conf);
I hope this will help. If you get any other queries regarding this, please post it here.