try { Runtime.getRuntime().exec("shutdown /h"); } catch (IOException ex) {}
Tutorials, tips and tricks about java programming language. Answers for many doubts about java programming language. Answering many howtos. Sample java projects and source code, java games, java programs for java practical labs.
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:
How to Launch a Application or Executable Using Java Code with Command Line Arguments
In this post, we shall see how to launch an application with its command line arguments using Java code. Most applications take path of a file as command-line argument to open it. If we give path of an image file to mspaint application as command-line argument, the image will be opened in paint. The following java program launches mspaint with a command-line argument which is a path to an image.
try { Runtime.getRuntime().exec("C:\\Windows\\System32\\mspaint.exe \"C:\\Users\\Shareef\\Desktop\\flower.jpg\""); } catch (IOException ex) {}
Arguments are separated by spaces. If a command-line argument contains space within it (such as a space in a path), it is recommended to enclose it within brackets.