Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode java launch.json args

I am trying to pass multiple arguments to my test java program in visual studio code:

public class test{

    public static void main(String[] args) {
        String x = args[0] 
        //String x = args[0] + arg[1];
        System.out.println(x);
    }
}

If I use 1 parameter in my launch.json, then it works:

    {
        "type": "java",
        "name": "Debug (Launch)",
        "request": "launch",
        "cwd": "${workspaceFolder}",
        "console": "internalConsole",
        "stopOnEntry": false,
        "mainClass": "",
        "args": "bla"
    }

But if i want to put 2 parameters, then it doesn't work. Tried a few combinations in my launch.json:

"args": ["bla","bla"],
"args": "bla" "bla",
"args": "['bla','bla']"

But then it looks like the debugger is hanging.

Thanks in advance.

like image 426
jk Registraties Avatar asked Aug 28 '18 15:08

jk Registraties


People also ask

How do I launch VS Code json?

To create a launch.json file, click the create a launch.json file link in the Run start view. If you go back to the File Explorer view (Ctrl+Shift+E), you'll see that VS Code has created a .vscode folder and added the launch.json file to your workspace.

Where is launch json in VS Code?

The launch. json file is located in a . vscode folder in your workspace (project root folder).

What does launch json do in VS Code?

A launch. json file is used to configure the debugger in Visual Studio Code. Visual Studio Code generates a launch.


1 Answers

You can pass multiple arguments in the same string, space-separated:

"args": "bla bla"
like image 153
Cameron637 Avatar answered Oct 26 '22 19:10

Cameron637