File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
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 ]

Ping & DNS - updated with new look and Ping home screen widget
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
 
Similar Threads
finalize method
javaprogramming
Compile a java program from another program
Using Runtime to invoke firefox in new window
y aint here class <classname>=new <classname> used and instead only class <classname> used