restart the System(windows 2000 and xp)

hai

MY application need to restart the os (windows 2000) through Java code.

i had tried but not restart my win 2000

class RestartWin2000

{

public static void main(String args[])

{

try

{

//Runtime.getRuntime().exit(10);

Runtime ref=Runtime.getRuntime();

//Process p=Runtime.getRuntime().exec("shutdown /r /t 30");

ref.exec("shutdown /r /t 30");

ref.exec("shutdown -r -t 00 -f");

ref.exec("shutdown /s /d");

ref.exec("restart.exe");

ref.exec("shutdown.exe");

}

catch(Exception e)

{

}

}}

Tell me some tipes to me

[652 byte] By [meqa] at [2007-10-2 5:57:13]
# 1
I think the only way to do this would be to write the native code to shutdown and then call it from Java using JNI.
swatdbaa at 2007-7-16 2:06:15 > top of Java-index,Java Essentials,Java Programming...
# 2
> hai > MY application need to restart the os (windows> dows 2000) through Java code.> ...> Tell me some tipes to meTip #1: It is very likely not your application's business to do that.
warnerjaa at 2007-7-16 2:06:15 > top of Java-index,Java Essentials,Java Programming...
# 3

1. Make sure your have rights to use "shutdown";

2. Make sure shutdown is a stand-alone program, not shell command like "dir". If it is shell command, you have to invoke shell to do it;

3. Does shutdown asks user about something? If yes, provide proper data to its input stream;

4. Does shutdown writes something on the screen when run from console? If yes read its output and error stream - otherwise it may stuck on blocked pipe;

5. Process exceptions caught and display them with stack trace. Or even easier, declare main as throws Throwable. Observe output;

6. Are you sure it is your app what should reboot machine ? :)

sztejkata at 2007-7-16 2:06:15 > top of Java-index,Java Essentials,Java Programming...