windows - running elasticsearch from java code -
i want run elastic search servlet. use method in servlet run elasticsearch not seem work.
ejbsessionbean.runcommand( "cmd c:\\elk\\elasticsearch\\bin\\elasticsearch";) the code runcommand follows:
public static void runcommand(string ch) throws ioexception { if (ch.length() <= 0) { system.err.println("need command run"); system.exit(-1); } runtime runtime = runtime.getruntime(); process process = runtime.exec(ch); inputstream = process.getinputstream(); inputstreamreader isr = new inputstreamreader(is); bufferedreader br = new bufferedreader(isr); string line; system.out.printf("output of running %s is:", ch); while ((line = br.readline()) != null) { system.out.println(line); } }
Comments
Post a Comment