I'm facing a weird problem. I'm a java beginner. I have to specificaly make a hardlink copy of one folder. This is the command if were to be used in CLI:
cp -al /home/hadoop/hdfs2/99/hdfs/* /home/hadoop/hdfs2/100/hdfs
The issue is rt.exec(command) simply fails with exit code 1. I already made the dest dir /home/hadoop/hdfs2/100/hdfs if theres any issue pops with that. However the command runs fine when ran over terminal. Also, the java runtime donot have issue executing echo "helo world" and returning inputstream.
Code:
Runtime rt = Runtime.getRuntime();
String command = "cp -al /home/hadoop/hdfs2/99/hdfs/* /home/hadoop/hdfs2/100/hdfs";
Process process;
String line;
try {
process = rt.exec(command);
process.waitFor();
int exitStatus = process.exitValue();
System.out.println(command);
System.out.println(exitStatus);
System.exit(1);
OUT:
cp -al /home/hadoop/hdfs2/99/hdfs/* /home/hadoop/hdfs2/100/hdfs
1