How to Get Input from Console in Java
Method 1 of 3:
For the Windows OS
- Click on the Start (Windows) Button.
- Navigate to the Control Panel.
- Find the Java Icon and double click on the same to open it.
- Once you enter the Control Panel, navigate to the tab named Advanced. Next, navigate to the Heading named as Java Console. Once you access the same, click on the radio button named Show Console. Next Click on Apply and then on the button named OK.
- Once you access the console, there are a number of different command prompts available to you. Select the appropriate one to complete the task. You can read the data from the console in two different ways.
- Buffered Reader.The first way is via the Buffered Reader command. The command for the same is shown below.
- Scanner .The second method is to use the Scanner command. The details of this command can be seen below
Method 2 of 3:
For the Windows 8 (and above)
- Click on the logo and W simultaneously.
- Search for Java Control Panel
- Click the icon to access the same.
- Once you enter the Control Panel, navigate to the tab named Advanced. Next, navigate to the Heading named as Java Console. Once you access the same, click on the radio button named Show Console. Next Click on Apply and then on the button named OK.
- Once you access the console, there are a number of different command prompts available to you. Select the appropriate one to complete the task. You can read the data from the console in two different ways.
- Buffered Reader.The first way is via the Buffered Reader command. The command for the same is shown below.
- Scanner.The second method is to use the Scanner command. The details of this command can be seen below
Method 3 of 3:
For the Mac OS
- Click on the logo of Apple located on the top left hand corner
- Navigate to the option named System Preferences
- You will notice the icon for Java.
- Click on the same to access the control panel.
- Navigate to the tab named Advanced. Next, navigate to the Heading named as Java Console. Once you access the same, click on the radio button named Show Console. Next Click on Apply and then on the button named OK.
- Once you access the console, there are a number of different command prompts available to you. Select the appropriate one to complete the task. You can read the data from the console in two different ways.
- Buffered Reader.The first way is via the Buffered Reader command. The command for the same is shown below.
- Scanner.The second method is to use the Scanner command. The details of this command can be seen below
4.5 ★ | 2 Vote