Use of the Runtime class

Source: Internet
Author: User

 Packagecom. System.Runtime;Importjava.io.IOException;/*runtime The class class mainly represents the environment in which the application runs.         GetRuntime () returns the running environment object for the current application.         The EXEC (String command) executes the corresponding executable file according to the specified path. Freememory () returns the amount of idle memory in the Java virtual machine.         Returns the maximum amount of memory that the Java virtual machine is attempting to use, in bytes maxmemory (). TotalMemory () Returns the total amount of memory in the Java virtual machine*//*Public class Runtimeuse {public static void main (string[] args) {Runtime RT = Runtime.getruntime (                  );                 System.out.println ("Returns the Environment object of the current application," +rt.getruntime ()); try {rt.exec ("C:\\windows\\system32\\calc").        EXE ");//Open a calculator} catch (IOException e) {e.printstacktrace ();         } thread.sleep (3000);        Process.destroy (); Returns the amount of free memory in a Java virtual machine.         In bytes System.out.println ("Idle memory in the Java virtual machine," +rt.freememory ());         Returns the maximum amount of memory that the Java virtual machine is attempting to use.         System.out.println ("The maximum amount of memory that the AVA virtual machine tries to use," +rt.maxmemory ());        TotalMemory () Returns the total amount of memory in the Java Virtual machine System.out.println ("Total memory in the Java Virtual machine," +rt.totalmemory ()); }}*///Open a program for 3 seconds and then close Public classRuntimeuse { Public Static voidMain (string[] args)throwsinterruptedexception {Runtime rt=Runtime.getruntime (); Try{Process PR=rt.exec ("C:\\windows\\system32\\calc. EXE "); Thread.Sleep (3000);    Pr.destroy (); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); }    }}    

Use of the Runtime class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.