I'm trying to set up VS code for java programming, and I'm kind of done. However one thing in particular bothers me. When I for example run the code below I get the output in the TERMINAL tab along with a lot of other junk that I don't want to see. How can I change it so that the only output is "Testing..." in the console?
public class Hello{
public static void main(String[] args){
System.out.println("Testing...");
}
}
The output after I run the code is shown in the figure below. Even if I click on the other tabs, they are empty and even if I remove/hide the terminal tab, each time I re-run the code it pops up regardless.
I found an even easier answer to this problem thanks to the tHeSiD's answer. To solve it and achieve the same result as tHeSiD, you can do it in the vsCode setting config user interface (also this approach will ensure this new setting will work for all other java projects).
To go to the VsCode setting ui, open vscode, then on top right go to file -> preference -> setting. Then once you are there, to apply the new setting, search launch.json in the search settings box and then scroll down and change the setting to this:
Afterward, if you go back to your java program and press f5, your "Hello World" should show up nice and clear in the Debug Console (It should work as I have tested it, but if it doesn't work, try relaunching vsCode).
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"args": "",
"console": "internalConsole",
"mainClass": "${file}"
},
]
}
Add this to your launch.json
file. The important option for you here is "console": "internalConsole",
This will output everything to the Debug Console tab and not terminal. And it will look clean like this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With