Getting console of the current runtime environment.

Getting console of the current runtime environment.

The Runtime class provides mechanism to get the console of the current runtime environment. Using this, we can perform needed actions on the console.


public class SystemConsole
   public static void main(String args[])
      SystemConsole systemConsole = new SystemConsole();
   private void proceed()
      System.out.println(“Getting handle of runtime Console”);
      Console runtimeConsole = System.console();
      System.out.println(“Got handle of runtime Console”);
      System.out.println(“You can now use runtimeConsole object to perform actions of your choice on”);


Expected output:

[root@mypc]# java SystemConsole
Objects.deepEquals(1,1): true
Objects.deepEquals(1,2): false
Objects.deepEquals(“abc”,”abc”): true
Objects.deepEquals(“aa”,”ab”): false



About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist