mxj object heaven (not...)

zigzag's icon

Hello,

I wonder if anyone has had trouble with the mxj object..
I've just built a java external invoking it with mxj that
1. calls an executable.
2. reads its output and prints it.

I've implemented the above logic in the bang method:

public void bang()
{
try
        {

            // launch EXE and grab stdin/stdout and stderr
            Process process = Runtime.getRuntime ().exec ("F:/test.exe");

            InputStream is = process.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line=null;
            while ((line = br.readLine()) != null)
            {
                System.out.println(line);
            }
        }
        catch (Exception err)
        {
         err.printStackTrace();
        }
    }

When i send a bang to that external, the patch launches the test.exe process but subsequently freezes (windows vista, maxforlive 5.1.7)
and prints the output when I kill the process with process explorer.

I tried to execute the same code in a java program and there it run successfully.
Does anyone know of issues with the mentioned readline methods in max/msp?
Any hints would be greatly appreciated.

warm regards

Jesse's icon

Without knowing what your external process is it's hard to say, but have you tried spawning a new Thread and executing the code there?

zigzag's icon

That did the trick! Many many thanks for pointing this out !