I am developing a tool simmilar to the mothurGUI-toolkit.

My actual problem is, that I try to interact with mothur from the virtual machine via Input/Output-streams.
I successful started mothur from java ( wihtout any parameters like so ‘C:/Mothur/mothur.exe’ )

The problem is, that mothur gives me the error that I missed some braces…
-> this occurs if you simple press enter when you start mothur from console.
So for me it seems, that mothur receives continuously the enter key, which I can’t figure out why.
I only start the app via a ProcessBuilder and print the output of mothur to the System.out-Stream of my IDE…

I did not gave mothur some input ( not that I know so far )… maybe there is a standard input character which
is ‘enter’ like ‘\n’ or ‘\r’?

What works is to start mothur with a batch file :slight_smile:

But I want a direct interaction with mothur too ( if this is possible ).



Thanks for contributing to mothur!

What’s in your system.out stream?

When the mothurGUI tool interacts with mothur it calls 1 command at a time. We chose to run it this way for several reasons. But primarily, it is because if there are any errors commands following will not be able to run. We capture mothur’s output to the screen to check for errors and output file names. You can run mothur one command at a time easily in script mode with commands like ./mothur “#summary.seqs(fasta=myFastafile);”

Hi westcott,

Thanks for your answer.

The System.out-Stream is the default Java OutputStream, it is a PrintStream, directing to the console - in this case to the output window of my
IDE ( Netbeans ).

You can run mothur one command at a time easily in script mode with commands like ./mothur “#summary.seqs(fasta=myFastafile);”

Yes, this is what I already got.
What I want too is an emulation of the command line tool of mothur.
When you start mothur without a file parameter it brings you the interactive mode window, where you can put commands by keyboard.
-> here I stuck, because of this immediately unwanted Enter I did not send mothur by the streams I control ( maybe it sends something anyway, even if I set the
outputstream for mothurs inputstream to null )

What I can access with Java are the two InputStreams( Standard Input and Standard Error , where I can receive everything mothur prints ),
and the single OutputStream( Standard Output where I can - if wanted - put some strings to send the mothur interactive tool some commands )



I would suspect the stream is feeding mothur something you are not expecting, perhaps a null string?? The source file in mothur where mothur gets inputs from the users is engine.cpp. There are 3 engines: the InteractEngine, BatchEngine and ScriptEngine. I am not sure if it would be helpful to you or not but I thought I would pass it along in case you want to play with mothur’s source so you can force mothur to spit out what the stream is giving it.


I still get stuck with the mothur interactive mode.
Here I provide a little test code for Java-developers

        ProcessBuilder pb = new ProcessBuilder( /** Set the path to mothur.exe ( for windows ) here, f.i. "C:/Mothur/mothur.exe" */ ); /** Set the working directory */ );
        // redirect std.output from mothur to java's std.input
        pb.redirectOutput( ProcessBuilder.Redirect.INHERIT );
        // redirect the input to mothur to System.out
        pb.redirectInput( ProcessBuilder.Redirect.INHERIT );

        // start the process
        Process mothurProc = pb.start();
        // ... now try to write something to mothur but how?
        // this won't work ...  
        Writer out = new BufferedWriter( new OutputStreamWriter( mothurProc.getOutputStream() ) );
        out.write( "help()" );

If you run the code above, you will see, that the intial text from mothur appears on the console of your IDE… or
the OS-console if you run the Java-class-file from console…

What you will not see is, that the command ‘help()’ is printed… :frowning:

Any ideas?

Best regards,


PS: this is not a real issue since the user can launch mothur by hand if he want. The main purpose is to automaticaly launch batch scripts or single commands with a GUI.
But I am pretty shure, that this is a solvable problem … and I want to fix this :wink: