'How to configure Visual Studio Code for Processing?

I am creating projects in Processing 3.5.3. I don't like the Processing IDE and want to use Visual Studio Code instead. I couldn't find a helpful source online (most didn't have the full instructions).

I installed the Processing Language extension in Visual Studio Code. In order to configure it, I created a file named Processing.pde, opened it, and then pressed Ctrl+Shift+P and typed Create Task File. I selected my workspace folder from the list in the Command Palette. I got a notification saying:

tasks.json already exists. Overwrite it?

I clicked Yes, and got another notification saying

Please add Processing to your path!

I have Processing in E:\processing-3.5.3-windows64\processing-3.5.3. I added this to the path variable (in System Variables) and tried again. But I got the notification again.

Am I adding the wrong path? How do I configure VSCode for Processing?



Solution 1:[1]

I had some problems figuring it out too. This GitHub page helped.

Your path should end with processing-java, and use \\ instead of \.

Example:

"processing.path": "C:\\Program Files\\processing-3.0.1\\processing-java",

Solution 2:[2]

Install the extension Code Runner! Ctrl + Shift + X

Go to Preferences JSON

Ctrl + Shift + P SEARCH PREFERENCES JSON Add This Into The JSON file

{"code-runner.executorMapByFileExtension": {
        ".pde": "cd $dir && mkdir $fileNameWithoutExt && cd $fileNameWithoutExt && copy $fullFileName ./ && processing-java --sketch=$dirWithoutTrailingSlash\\$fileNameWithoutExt  --run && rmdir $fileName && cd $dir && rmdir $fileNameWithoutExt"
    }
}

To Compile And Export, Use This Instead

{
"code-runner.executorMapByFileExtension": {
        ".pde": "cd $dir && mkdir $fileNameWithoutExt && cd $fileNameWithoutExt && copy $fullFileName ./ && processing-java --sketch=$dirWithoutTrailingSlash\\$fileNameWithoutExt --output=\"$workspaceRoot\\output\" --force --variant=windows-amd64 --export  && processing-java --sketch=$dirWithoutTrailingSlash\\$fileNameWithoutExt  --run && rmdir $fileName && cd $dir && rmdir $fileNameWithoutExt"
    }
}

To Compile And Export Without Java, Use this instead

{
"code-runner.executorMapByFileExtension": {
        ".pde": "cd $dir && mkdir $fileNameWithoutExt && cd $fileNameWithoutExt && copy $fullFileName ./ && processing-java --sketch=$dirWithoutTrailingSlash\\$fileNameWithoutExt --output=\"$workspaceRoot\\output\" --force --variant=windows-amd64 --no-java --export  && processing-java --sketch=$dirWithoutTrailingSlash\\$fileNameWithoutExt  --run && rmdir $fileName && cd $dir && rmdir $fileNameWithoutExt"
    }
}

This is a very round about way of doing this process with the help of cmd commands, It is much easier to simply just use Processing IDE

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Das_Geek
Solution 2 Mathew