On Mon, Jun 6, 2011 at 5:02 PM, ANAMIKA CHAUHAN
<[email protected]> wrote:
>
> Hello friends,
> I am making an application in which I need to shutdown unix system through
> gui interface..I am trying to do this work through java.
> I tried this code on my fedora for shutting system down .Its not working...I
> did this work in windows ..its working there but not on fedora.............
>
>
> import java.io.IOException;
>
> public class Main  {
>
>     public static void main(String[] args)throws IOException {
>         Runtime runtime=Runtime.getRuntime();
>         Process proc=runtime.exec("shutdown now  -h 0");
>         System.exit(0);
>            }
> }

1. Make sure that this code is running as root.
2. Try        Process proc=runtime.exec("/sbin/shutdown now");
If that works, add the "-h". Why do you have a zero after -h?


SB

-- 
Mailing list guidelines and other related articles: http://lug-iitd.org/Footer

Reply via email to