Run any command via Java, You can even shutdown your computer

Recently I cam across a tutorial site that allowed to copy your code in a textarea and then allowed to execute the java program. Although the intent of the site was good but anyone with bad intentions could disrupt this site easily and execute any command.

Here is a program that you can run to shutdown you computer.


 * @author tak

public class ShutdownWindows {

 public static void main(String[] args) {
  try {
   Runtime.getRuntime().exec("shutdown -r");
   // use this command for max os x and linux :-  shutdown -r now
  } catch (IOException e) {



Like this post? Don’t forget to share it!