Runtime of Java

Source: Internet
Author: User

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. In bytes

MaxMemory () returns the maximum amount of memory that the Java virtual machine is attempting to use.

totalmemory () returns the total amount of memory in the Java virtual machine

Import Java.io.ioexception;public class Demo03 {public static void main (string[] args) throws IOException, Interruptedexc eption {Runtime runtime = Runtime.getruntime (); Process process = Runtime.exec ("C:\\windows\\notepad.exe"); Thread.Sleep (3000); Let the current program stop for 3 seconds. Process.destroy (); SYSTEM.OUT.PRINTLN ("The amount of idle memory in the Java Virtual machine. "+runtime.freememory ()); SYSTEM.OUT.PRINTLN ("Maximum amount of memory that the Java virtual machine is trying to use:" + runtime.maxmemory ()); System.out.println ("Returns the total amount of memory in the Java virtual machine:" + runtime.totalmemory ());}}

Execution results

The amount of idle memory in the Java Virtual machine. 124864272Java virtual machine attempts to use the maximum amount of memory: 1879048192 returns the total RAM in the Java virtual machine: 126877696


Runtime of Java

Related Article

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.