I have the following class. It allows me to execute commands through java.
public class ExecuteShellCommand {
public String executeCommand(String command) {
Each invocation executes in it's own shell. Thus the "cd" of the 2nd invocation is not seen by the third.
See: https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String).
This states that the command is run in a separate process. Thus you have spawned 3 processes.
If you want all 3 in the same process, try this:
com.executeCommand("ls; cd bin; ls");