microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.48k stars 28.65k forks source link

In vscode, how to set different jdk versions for different folder projects in the same workspace #154086

Closed np7sky closed 2 years ago

np7sky commented 2 years ago

Does this issue occur when all extensions are disabled?: Yes/No

Issue Type: Bug

  1. Create two normal Java projects, the bytecode project using Java8, the bytecode1 project using Java17, and configuring settings.json in the .vscode folder.
  2. close bytecode1 project window.
  3. bytecode project : File->add folder to workspace.
  4. full compile,run,
  5. Then the JDK versions of the two projects are the same.

Extension version: 0.24.0 VS Code version: Code 1.68.1 (Universal) (30d9c6cd9483b2cc586687151bcbcd635f373630, 2022-06-14T12:52:13.188Z) OS version: Darwin x64 21.5.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|2, 2, 2| |Memory (System)|32.00GB (8.87GB free)| |Process Argv|--crash-reporter-id 1572d73b-eb3a-42e2-b7ac-ea8295a90847| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vstes627:30244334 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 vscscmwlcmt:30465135 cppdebug:30492333 vscaac:30438847 pylanb8912:30520716 vsclangdf:30486550 ```
2022-07-04 19 55 37

bytecode-settings.json(Project that need to be upgraded to jdk8)


{
"java.project.sourcePaths": [
"src"
],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
],
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
"default": true
}
// ,
// {
//     "name": "JavaSE-11",
//     "path": "/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home",
//     "default": true
// }
// },
// {
//     "name": "JavaSE-17",
//     "path": "/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home",
//     "default": true
// }
]
}

> bytecode1-settings.json

{ "java.project.sourcePaths": [ "src" ], "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/*/.jar" ], "java.configuration.runtimes": [ { "name": "JavaSE-17", "path": "/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home", "default": true } ] }

upgradejdktest workspace.json file

{ "folders": [ { "path": "/System/Volumes/Data/pit_pro/study/tmp/bytecode" }, { "path": "/System/Volumes/Data/pit_pro/study/tmp/bytecode1" } ], "settings": { "java.project.sourcePaths": [ "src" ], "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/*/.jar" ] } }

np7sky commented 2 years ago

The requirement is that I need to develop in a window, partially split the old services, improve the processing power of certain functions, and be asked to use the new JDK version. Legacy services will remain in production until they are fully upgraded.

gjsjohnmurray commented 2 years ago

/extJava

VSCodeTriageBot commented 2 years ago

It looks like this is caused by the Java extension. Please file the issue to the Java extension repository. Make sure to check their troubleshooting instructions and provide relevant information such as the extension version you're using. See also our issue reporting guidelines for more information.

Happy Coding!