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()));
while(true)
{
String line=br.readLine();
if(line==null)
      break;
else {
      //Do whatever you want
}

Run Dialog on Windows Mobile

imageI learned this very neat trick last summer; however, a couple of months ago I couldn’t find the information again. Now that’ I’ve found it again, I wanted to share it here so that I do not lose it 🙂

By using a key combination, you can actually make the Run dialog which we are all accustomed to, to show up on Windows Mobile too.

It is really like the one on Windows, and you can add command-line parameters too. (like the one in the picture; you can open IE with a predefined address)

Hold the Action hardware button and then tap and hold the time display at the top right of the screen. When you release the stylus, a menu will popup. Select the Run option and there it is! Enter the full path of any executable on the device with any parameters you may like to give.

Create/delete/start/stop a service from command-line

For some reason, I just needed to do something like this, so here is a quick how-to:

There is a tool named sc.exe in the Win 2K Resource Kit, however I believe it also exists in Windows XP, as I did not have to do anything, and was able to access it from command-line.

Using this tool, you can see the list of the services that are currently running, add, delete, create or stop services.

The syntax for creating a service is like this:

Read the rest of this entry »