|
|
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.
|
|

06-17-2008, 12:54 AM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 14
|
|
|
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?
|
|

06-17-2008, 08:26 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
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.
|
|

06-17-2008, 04:21 PM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 14
|
|
|
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?
|
|

06-17-2008, 05:54 PM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 14
|
|
|
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...?
|
|

06-18-2008, 06:14 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
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.
|
|

06-18-2008, 04:58 PM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 14
|
|
|
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?
|
|

06-19-2008, 09:36 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
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.
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.
|
|

06-19-2008, 10:23 AM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 338
|
|
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:
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.
|
|

06-19-2008, 10:26 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
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.
|
|

06-19-2008, 10:32 AM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 338
|
|
|
yes the code is the same,but read the post up to the end.
|
|

06-19-2008, 10:56 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
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.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|