The code underlying the "create" command reads the password using System.console().readPassword() [1]. This is different from all the other inputs which use Scanner.nextLine() [2] based on System.in [3].
It's not clear why you're actually trying to do this rather than just using org.apache.activemq.artemis.cli.commands.Create directly. Seems like it's going to be a bit of a mess if it's even possible. Justin [1] https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Console.html#readPassword() [2] https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Scanner.html#nextLine() [3] https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/System.html#in On Thu, Jan 20, 2022 at 8:18 AM Goel, Amithkumar <amithkumar.g...@sap.com.invalid> wrote: > Hi all, > > > > I wanted to create artemis broker instance via interactive mode using a > Java application. I have written a sample code to execute the windows > command and provide the input in an interactive mode kindly find the java > file as an attachment. > > > > Now if I run the command as below where all input like username, password, > etc is given in the command itself it works fine: > > String command = "<Java_home>\\jre\\bin\\javaw.exe\" -XX:+UseParallelGC > -XX:+AggressiveOpts -Xms512M -Xmx1024M -classpath > \"<ARTEMIS_HOME>\\java\\lib\\artemis-boot.jar\" > -Dartemis.home=\"<ARTEMIS_HOME>\\java\" > org.apache.activemq.artemis.boot.Artemis create --user "Administrator" > --password "Password1" --role admin --allow-anonymous y > \"E:\\MessagingQueueBroker1\""; > > > > But if I run the command in interactive mode as below: > > String command = "<Java_home>\\jre\\bin\\javaw.exe\" -XX:+UseParallelGC > -XX:+AggressiveOpts -Xms512M -Xmx1024M -classpath > \"<ARTEMIS_HOME>\\java\\lib\\artemis-boot.jar\" > -Dartemis.home=\"<ARTEMIS_HOME>\\java\" > org.apache.activemq.artemis.boot.Artemis create > \"E:\\MessagingQueueBroker1\""; > > > > Then it asks for the input in an interactive way, and I am providing the > input via java code. > > > > BufferedWriter writer = new BufferedWriter(new > OutputStreamWriter(process.getOutputStream())); > > writer.write("Administrator\n"); > > writer.flush(); > > ……… > > > > It gives an exception “The pipe is being closed” while providing the > password but it is working fine for all other parameters. Do anyone have > solution w.r.t this issue. I want to run command in interactive mode only. > > > > Regards, > > Amith Goel. > >