vscode-java-debug
vscode-java-debug copied to clipboard
Single file support
User feedbacks:
- "Single file support. Some times i want to run a single file nothing else. I don't want errors from other files in the folder. There should an option ."
- I use VSCode for simple single file java programs. A simple run / debug button, which does not add everything to the classpath and tries to compile all of the other java files would be great.
@testforstephen you often have tricks / workarounds - any come to mind for this? 😄
Actually I found that the Run/Debug menu works when I opened things up in a dedicated folder - switching files does run the proper file. But it wasn't working a while back so not sure what changed I was doing wrong before
I created a .vscode/tasks.json file
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "compile current file",
"type": "shell",
"command": "javac ${file}",
"group": "build",
"problemMatcher": [],
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": ["/d", "/c"]
}
}
},
"linux": {
"options": {
"shell": {
"executable": "bash"
}
}
},
"options": {}
},
{
"label": "run current file",
"type": "shell",
"command": "java ${fileBasenameNoExtension}",
"group": "build",
"problemMatcher": [],
"dependsOn": "compile current file",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": ["/d", "/c"]
}
}
},
"linux": {
"options": {
"shell": {
"executable": "bash"
}
}
},
"options": {}
}
]
}