How to get the output of a console application from Java

Of course; I was trying to get a thread dump using jstack here. You would need to change the command that Runtime.exec() executes to your liking.

Process threadDump=Runtime.getRuntime().exec("jstack -l "+pid);
BufferedReader br=new BufferedReader(new InputStreamReader(threadDump.getInputStream()));
String line=br.readLine();
else {
      //Do whatever you want


How to get the process id after running an application from Java under Linux

Use the following sample code to get the pid(process id) on *nix variants, after running it as a command from Java using Runtime.exec() .

The command variable, in my case, was running another Java application.

try {

Process  process=Runtime.getRuntime().exec(new String [] {"sh","-c",command+"  &  echo $!"} );
BufferedReader br=new BufferedReader(new InputStreamReader(process.getInputStream()));

String ps=br.readLine();
int pid=Integer.valueOf(ps);
} catch (IOException e2) {
// TODO Auto-generated catch block

Java IDEs

Recently, I needed to head out into the Java environment to write servlets, jsps, and JME applications for a project that I am enrolled in at my internship. So I looked up for IDEs(integrated development environment) to work with. I have used Eclipse and NetBeans until now and I think NetBeans is the best based on my experience and the articles that I have read on the internet. I really don’t know why Eclipse is known around so much better than NetBeans. The NetBeans IDE comes with sample applications for EJB, UML, JSF. And also you can develop JSF applications visually with the editor.

Read the rest of this entry »