This is my code:
public static void main(String[] args) throws Exception { String[] cmd = {"which", "hive"}; Process proc = Runtime.getRuntime().exec(cmd); BufferedReader reader = new BufferedReader( new InputStreamReader( proc.getInputStream() ) ); String line = ""; while((line = reader.readLine()) != null) { System.out.print(line + "\n"); } proc.waitFor(); } In my terminal:
which hive:/home/as/hive/bin/hive which gcc:/usr/bin/gcc But when I run this java code:
which hive:no result which gcc:/usr/bin/gcc I've added $HIVE_HOME into ~/.bashrc (I'm using Ubuntu 14.04 64 bit and Java 8), so what should I do now?
System.out.println(System.getenv().get("PATH"));