-1

I experimented with java code that expected user input. However, I am unable to type anything in the Visual Studio Code Editor's designated space. To fix this issue, I installed the Java Development Pack Extensions, but nothing worked.

import java.util.Scanner;

public class App {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int age;

    System.out.println("Enter age:");
    age= sc.nextInt();
    
    
  }
}

I used Visual Studio Code editor to try and get user input; normally, I use Intellij Idea editor. As a result, I am unable to type anything on the console to provide input when using the Visual Studio Code Editor to write Java programs. So, please offer your assistance in finding a solution.

Nexevis
  • 4,647
  • 3
  • 13
  • 22
risni
  • 19
  • 4
  • 1
    Did you take a look at this [question](https://stackoverflow.com/questions/71030502/visual-studio-code-is-not-taking-input-from-keyboard-when-i-use-c-or-java)? I am not familiar with VS code, but it seems to be same problem. – Nexevis Aug 31 '23 at 13:09
  • thank you for your assistance I did it that way and now it works well – risni Aug 31 '23 at 13:27

1 Answers1

2

I suggest you to check the official website of Visual Studio Code editor about this topic.

Link to the topic

Especially the part:

Debug session inputs The default Debug Console in VS Code doesn't support inputs. If your program need inputs from a terminal, you can use the Integrated Terminal (Ctrl+`) within VS Code or an external terminal to launch it. You can also use the user setting java.debug.settings.console to configure a global console for all Java debug sessions.

Part can be useful for you. Good luck!