I am using Visual Studio Code 0.9.2 on OS X Yosemite to edit a .java file.
I attempt to compile this file using the following tasks.json file:
{
"version": "0.1.0",
"command": "javac",
"isShellCommand": true,
"echoCommand": true,
"showOutput": "always",
"args": ["-d","${workspaceRoot}\/target","${workspaceRoot}\/src\/*.java"]
}
Executing this task echoes the following command to the Output window:
running command$ javac -d /Users/caoimheboers/Desktop/JLab11/target
/Users/caoimheboers/Desktop/JLab11/src/*.java
... which is fine, however the result of the task execution is then reported as:
javac: file not found: /Users/caoimheboers/Desktop/JLab11/src/*.java
Usage: javac <options> <source files>
use -help for a list of possible options
I have tried the following:
Copy the echoed javac command (including all arguments) from the Output window and paste it to the command line in a Terminal window. Result: The single .java file in the /src folder compiles and a .class file appears in the /target folder. This indicates that the syntax of the javac command (including all arguments) is correct in the tasks.json file.
In the tasks.json file, replace the wildcard character with the name of the single .java file in the /src folder. Result: The VS Code task runs perfectly, and produces a .class file in the /target folder. This indicates that everything about the command in the tasks.jason file is OK except for the wildcard character.
Any ideas on what I'm doing wrong?
Task auto-detection Below is an example of the tasks detected for the vscode-node-debug extension. Tip: You can run your task through Quick Open (Ctrl+P) by typing 'task', Space and the command name.
The problem matcher to be used if a global command is executed (e.g. no tasks are defined). A tasks. json file can either contain a global problemMatcher property or a tasks property but not both.
${workspaceFolder} - the path of the folder opened in VS Code. ${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/)
You need to configure the tasks in a tasks. json file (located under your workspace . vscode folder) if you want to do more than simply run the task.
I also experienced it, it was apparently a bug. Currently there is a new terminal runner which fixes this error. Try to change the tasks JSON schema to new 2.0.0 version, reload the window and everything will be fine:
{
"version": "2.0.0",
"command": "javac",
"isShellCommand": true,
"echoCommand": true,
"showOutput": "always",
"args": ["-d","${workspaceRoot}/target","${workspaceRoot}/src/*.java"]
}
The related issue is here: https://github.com/Microsoft/vscode/issues/16865
You don't need to escape the slash character by the way.
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