Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2008, 12:54 AM
Member
 
Join Date: Jun 2008
Posts: 14
jmHoekst is on a distinguished road
Determining the readiness of another program
Greetings,

I am looking for ideas on how to be able to tell if a program is fully loaded and ready for input. I am using

Runtime.getRuntime().exec("programName");

to start my program and the program can take between 10 seconds and 10 minutes to load. After the program is loaded, I have several automation steps being done, so they can't be started until the program has loaded.

Any ideas on how I can interact with my Windows XP os to determine if the program is ready for input? Whether it is using Java, or some other language/technique?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-17-2008, 08:26 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Loading a program means, initialize all the process to make required functionality. So you have a sequence of processes. If you know what is the last process to load, until it's successful disable the user interactions with the application. Just an idea this is, on what I thought the easy way.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-17-2008, 04:21 PM
Member
 
Join Date: Jun 2008
Posts: 14
jmHoekst is on a distinguished road
Is there some kind of a way to perhaps get the %cpu usage from the system? That would be a perfect indicator of the system readiness. Maybe through JNI? Anybody have any ideas?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-17-2008, 05:54 PM
Member
 
Join Date: Jun 2008
Posts: 14
jmHoekst is on a distinguished road
Eranga,

What you are saying sounds very good, but what tools are necessary to determine if the last process is successful? Either way, I think I will have to use a JNI or interface with C or VB to determine CPU %? Unless somebody has an alternative solution or suggestion...?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-18-2008, 06:14 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Not a bad idea though. But how we define the CPU usage level. I mean how can we find that looking the usage a specific process is completed. Just look at the CPU usage without doing any on your system. Still you can see that usage level change from 0% to up, and upper level has no pre-defined level.

If you want to find the CPU usage, best solution is C/C++ interface, I think.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-18-2008, 04:58 PM
Member
 
Join Date: Jun 2008
Posts: 14
jmHoekst is on a distinguished road
Thanks for the advice Eranga, I have since made a small VBScript that will get the current CPU% on my system. Now, how would I use my Java program to call that script, and how would I get the value from the VBScript to my Java program?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 06-19-2008, 09:36 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I've never do this. I hope using a runtime process we can run a VBScript. But the question is how to handle the output of the script. This is the way to run a script.

Code:
Runtime.getRuntime().exec("wscript.exe path_to_your_script");
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 06-19-2008, 10:23 AM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 338
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Last monthes we are working for a driver center in Java code for Linux Sam,and to have an output of the command we do the following:

Code:
import java.util.*; import java.io.*; import javax.swing.*; public class Shell { private static String command = "ls -Als"; private static String command2 = "cat /etc/profile"; private String string=""; public static void main(String[] args) throws java.io.IOException { JFrame frame=new JFrame("Output"); JTextArea textArea=new JTextArea(); textArea.setEditable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.getContentPane().add(textArea); frame.setSize(500,800); frame.setVisible(true); try { Process child = Runtime.getRuntime().exec(command); // Get the input stream and read from it InputStream in = child.getInputStream(); int c; while ((c = in.read()) != -1) { textArea.append(String.valueOf((char)c)); } in.close(); } catch (IOException e) { } try { Process child = Runtime.getRuntime().exec(command2); // Get the input stream and read from it InputStream in = child.getInputStream(); int c; while ((c = in.read()) != -1) { textArea.append(String.valueOf((char)c)); } in.close(); } catch (IOException e) { } } }
You can do the same for windows,you can also access the PCB table to know if the process is launched and then to go with the next command.

I know the shell command to know if the process launched in Linux,but there is also a dos command for that,search for it buddy.

Last edited by serjant : 06-19-2008 at 10:26 AM.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 06-19-2008, 10:26 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
What this replay mean. Seems to me there is no any connection with the original thread. I see that you have post the same post in several threads.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 06-19-2008, 10:32 AM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 338
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
yes the code is the same,but read the post up to the end.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 06-19-2008, 10:56 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I got you. Rather adding code the best thing is explain well. With a code it should be much better.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a program within a program gibsonrocker800 New To Java 5 05-12-2008 10:24 AM
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 04:40 PM
Determining Midi Length Usagi New To Java 0 12-09-2007 01:45 AM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 11:33 PM
I need help with this program Daniel Advanced Java 2 07-04-2007 07:14 AM


All times are GMT +3. The time now is 12:26 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org