• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rumtime  RSS feed

 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.swing.*;
import java.io.*;
public class Add {
public static void main(String args [])
{
try {
String command = "times";
Process child =Runtime.getRuntime().exec(command);
} catch (IOException e) {
System.out.println(e);
}
}}

it is catching exception what the problem in it
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is times a valid command on your operating system? If it is a program you should use "times.exe".
On windows if I try to run the times command in a DOS window I get:
'times' is not recognized as an internal or external command, operable program or batch file.

So of course java could not execute it either.
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the coomand is time not a times but its give me the ioexception of creat process
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try
String command = "cmd /k start time";
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but it throws
java.io.Exception : CreateProcess : cmd /k start time error = 0
cmd is the dos that im talking about
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ali,
I think the following article may help you (if you haven't already seen it):
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Hope this helps you.
Good Luck,
Avi.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works for me on a Win2000
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mmmm... rum time...
Sorry, thought I was in MD for a second.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!