Search This Blog

Showing posts with label logout. Show all posts
Showing posts with label logout. Show all posts

Java Program to Hibernate Windows Operating System

Do you want to hibernate your Windows computer using java program? This is a java program to hibernate Windows operating System. If you execute this java program, it will hibernate your Windows computer instantly. The following is the java code to hibernate Windows:

try
 {
 Runtime.getRuntime().exec("shutdown /h");
 } catch (IOException ex) {}

How to Logoff or Sign Out Windows Using Java Code

You can sign out the current user account from windows using java code. Sign out, log out or logoff button can be created using simple lines of code. To logout from Windows operating system using java code, use the following code:


try {
        Runtime.getRuntime().exec("shutdown /l");
    } catch (IOException ex) {}

As the above code shows, we are simply executing a cmd command shutdown /l. It is actually running shutdown.exe with parameter /l to force logoff. If you add above code in the actionPerformed() function of a button, the button becomes a logoff button. The following video will show an example in which a simple button is made into a logout button.