This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to get activation time of an external application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get activation time of an external application" Watch "How to get activation time of an external application" New topic

How to get activation time of an external application

pavan kumar singaraju

Joined: Aug 29, 2005
Posts: 5
to know the activation of an external application how to proceed in java?. I mean consider for example you are opening a browser. from opening the browser till it gets activated it will take some time. How can i get this activation time?. The basic problem i am looking at is how to synchronize the two, my java application that is trying to open the application and the external application.
thanks in advance
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3640

I strongly believe that the time to activate external application from Java is not consistent, because if recourses at OS level are not free then it will tale more time, otherwise less.

But still you can use measure using following method

My blood is tested +ve for Java.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Also remember that just because a call to run a program returns, it does not guarantee the program is executing. It may have failed immediately with error messages, or returned immediately because it only allows one instance and one is already running.
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3640
Can you send me your busness requirment?

May be someone may suggess you better way.
pavan kumar singaraju

Joined: Aug 29, 2005
Posts: 5
A Project in Linux is requiring this particular approach for optimizing the Linux kernal. They are documenting the various approaches of finding the above said one. i.e., to optimize the some kernal process handling things, they need to find how much time is being taken for the application to get activated is needed. In that process they enquired how can it be done in java and i too wanted as it is an interesting exploration. I thought of sharing of knowledge here in javaranch. This is the sinerio for this querry.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

This is really silly. Optimizing a kernel by launching a browser and timing how long till it appears -- in Java?

Let's break this down, shall we?

1) The vast majority of the work of launching a browser is done in user space, not kernel space.

2) The timing is strongly dependent on what else is running, the state of VM, graphics memory, etc. There's simply no way you'd ever get meaningful results that meant anything outside of the one test machine.

3) Java has no way to interact with the windows of other applications, so to do this in Java, you'd have to use native code -- so why use Java?

4) Java, being a garbage collected language, is a bad choice for precise timing of anything, let alone another process.

5) The tiny timing differences due to kernel optimizations would be absolutely swamped by the timing differences due to the fact that you're timing one process via messages passed to another process. The only way you could possibly get useful results would be by instrumenting the browser app itself -- otherwise you'd end up optimizing the kernel's scheduler to minimize the time between browser launch and timing measurement.

My advice is not to waste your time with this.

[Jess in Action][AskingGoodQuestions]
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
You are really amazing, Ernest Friedman-Hill. And a great source of inspiration for me.

I always try to read each and every post of yours. I really feel your (near-perfect) knowledge has no bounds. This is not to mention the excellent English.

I agree. Here's the link:
subject: How to get activation time of an external application
It's not a secret anymore!