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
}

Advertisements

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
e2.printStackTrace();
}

Running Windows 95 on iPhone

So what do you think?

Not that this is a great invention; as it has already been done before on other phones(e.g. Mac OS or Windows 95 on N800 on the Maemo platform) using emulators; but it is nice to know that it is indeed possible.

Read the rest of this entry »

Rapidshare Link Checker in C# – Source Code

I’ve created a simple validity checker desktop application for Rapidshare links.

I am giving out the source code and the binary, in case anyone is interested.

Read the rest of this entry »

Became an MCP

Hi everyone! I have been inactive in the blog lately, but since school is over, I will now be able to devote more time and attention here.

MCP(rgb)I attended a MS certification exam recently(well, last week), thanks to Microsoft’s free exam voucher for students, and I passed it 🙂 So I am now officially a MCP. 

 

The exam that I sat for was “TS: Microsoft .NET Framework: Application Development Foundation” btw.

Anyway, just wanted to share the news. See ya!

Enable/Disable /Change IE Proxy by script/programmatically

Ok. You know the drill, you need to use the company’s proxy server at work and at home you don’t need a proxy server.(or you use another one)

Well, do you really want to open up IE and go into Tools->Internet Options->Connections->LAN Settings->Proxy Server to change the address or disable/enable it?

(You can actually open Internet Options from Control Panel without opening up IE, but anyway, it still is a long process.)

As everything useful is done in Registry in Windows, we again have some registry scripts.

Read the rest of this entry »