Click here to Skip to main content
15,888,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to run the erlang command from java code.i already did the coding but the problem is i am unable to run code in terminal.the command for running erlang i.e "erl" doesnot get started.

code:
Java
public class erlcmd {

    public static void main(String[] args) throws Exception{

        String command[] = {"erl","2 + 3."};
        for(int i=0;i<command.length;i++)>
        {
            Process proc = Runtime.getRuntime().exec(command[i]);
            
            // Read the output
            
            BufferedReader reader =  
            new BufferedReader(new InputStreamReader(proc.getInputStream()));
            
            String line = "";
            while((line = reader.readLine()) != null) {
                System.out.print(line + "\n");
            }
            proc.waitFor();   
        }
    }
}
Posted
Updated 10-Mar-15 22:33pm
v2

1 solution

Your call to exec is only sending the first element of the array: the command name without the parameters. It should be:
Java
Process proc = Runtime.getRuntime().exec(command);

as described at http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String[])[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900