0

I am trying to start a Hive server using Java program.

This is my Java code.

p = Runtime.getRuntime().exec("/home/bigdata/hive/bin/hive --service hiveserver");
p.waitFor();

Error:

Cannot find hadoop installation: $HADOOP_HOME or $HADOOP_PREFIX must be set or hadoop must be in the path

I started my hdfs. But also i am getting this error

Suresh Ram
  • 1,034
  • 3
  • 16
  • 40

1 Answers1

0

Runtime.exec() is not going to run your .bashr, see Bash Startup Files. Your exec() call process should inherit your caller environemnt, but apparently the caller is missing the HADOOP_HOME. I can't guess why is that, probably something related to how/when is your own Java program invoked. One way to fix it is to run bash -l -c hive --service ... if you want bash to run the startup files and then run your command. But probably a better approach is to explicitly set the environment you want to pass down to your process. See How do I set environment variables from Java?

Ultimately, why? Usually all hive services should be started from init.d

Community
  • 1
  • 1
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569