aspose file tools*
The moose likes Beginning Java and the fly likes Error in program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in program" Watch "Error in program" New topic
Author

Error in program

Parveen Dalal
Greenhorn

Joined: Jun 24, 2007
Posts: 8
Hello Friends,
I made a program but it shows a error so please give me the solution. thanks in advance.

class Xyz {
public static void main(String args[])
{
try
{
Runtime rt = new Runtime.getRuntime();
Process p = rt.exec("shutdown -s -t 1000");

}
catch(Throwable t)
{
t.printStackTrace();
}
}
}

Error is :
Xyz.java:6: cannot find symbol
symbol : class getRuntime
location: class java.lang.Runtime
Runtime rt = new Runtime.getRuntime();
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42952
    
  73
Runtime rt = new Runtime.getRuntime();

You can't instantiate Runtime. It should read "Runtime.getRuntime(...)", not "new Runtime.getRuntime(...)".

And if you could instantiate it, it would be "new Runtime()", not "new Runtime".
[ July 28, 2007: Message edited by: Ulf Dittmer ]
Parveen Dalal
Greenhorn

Joined: Jun 24, 2007
Posts: 8
Thanxs alot its work
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in program