1

I'm currently trying to use a different java version for testing purposes. But I can't get the newly added java version show up in VS Code. I added it in my settings.json like this:

settings.json

But it doesn't show up as a selectable version on the "Configure Runtime for Projects" menu:

Configure Runtime for Projects

As you can see only jdk 17 is listed in the dropdown, not the jdk 14. Am I doing something wrong?

PS:

"Reinstalling" the Java version is not an option because it's an downloaded zip file and no installer exitst for this version.

EDIT:

The way I'm trying to do is also recomended on their github page.

UPDATE:

While trying some things I removed everything Javaisch from my environment variables. Now no JDK is listed in the drop down above. But VS Code still somehow finds my JDK-17 and runs Java programs. When I set JDK-14 as "JAVA_HOME" VS Code uses the JDK-14 version. But this is not my goal. I want multiple Java versions selectable in VS Code (which the menus are designed for) it just doesn't work.

RedCrafter LP
  • 174
  • 1
  • 8
  • Not that I know the solution, but it seems to dislike something about ".runtimes" part of the key. Maybe that has some explanation about why options aren't picked up properly? In your version selector, for example, it doesn't respect the name, so most likely that configuration option is ignored in favour of some other option entirely. – M. Prokhorov Jun 24 '22 at 16:28
  • that's just my spelling extension for some reason not recognizing the word "runtimes" as a valid word. But thanks ; ) – RedCrafter LP Jun 24 '22 at 16:30
  • Does this answer your question? [How to work with VSCode and multiple java versions](https://stackoverflow.com/questions/68957396/how-to-work-with-vscode-and-multiple-java-versions) – Kaan Jun 24 '22 at 16:31
  • No, I actually read this post. But the answer talks about selecting it from the drop down shown above. (Which doesn't work). One comment is complaining about the same issue I have but never gets answered. – RedCrafter LP Jun 24 '22 at 16:36
  • That's an extra comma at the end of the path for the Java 14 object. It could be that it doesn't find the jdk-14 because the json is malformed. Also, I see you are using the Unix separator "/" and have a C: drive, Windows style. If your using Windows, it wouldn't hurt to try using the right, escaped separator "\\", like `"path" : "C:\\Java\\jdk-14-Valhalla"`. – Jetto Martínez Jun 24 '22 at 16:41
  • Sadly didn't change a thing – RedCrafter LP Jun 24 '22 at 16:52
  • Create a batch file to switch between Java 17 and Java 14. The code should change the value of Java_Home environment variable –  Jun 24 '22 at 17:23
  • That's the solution proposed in Kaan's link and it's not what I'm asking for. I'm trying to find out why my (officially recommended) approach doesn't work. – RedCrafter LP Jun 24 '22 at 17:33

1 Answers1

0

This works fine on my machine, which originally only had Java17, now it can choose between Java14 and Java8.

enter image description here

So make sure you have correctly installed Java14, otherwise it won't show up in the dropdown options.

Method 1: Install other versions of Java through the Configure Java Runtime panel

enter image description here

Method 2: Download the Java version on the Internet and install it.

I downloaded and installed Java14 here: java14

enter image description here

PS: I restore all settings to default or reinstall vscode without any settings. It recognizes all three versions of Java.

JialeDu
  • 6,021
  • 2
  • 5
  • 24
  • This is explicitly not an option as stated in the question. The version of java14 is dev build. It therefore does not have an installer you can download. I'm looking for a way to register a java version the same way the installer does. So that I can select it in vsCode. – RedCrafter LP Jun 28 '22 at 12:28
  • Can you provide the Java14 version you are using? – JialeDu Jun 29 '22 at 08:57
  • It doesn't matter but here:https://jdk.java.net/valhalla/ – RedCrafter LP Jul 01 '22 at 14:11
  • Do you want this effect? It's like [this](https://imgur.com/tkwzAM8) on my machine. Also, doesn't the Java14 linked in the answer work for you? – JialeDu Jul 04 '22 at 06:19
  • This is exactly what I want. But I can't find a way to "inform" VSCode that these versions exist. You probably installed them with the installer right? And again installing release Java 14 is not an option because I am testing in the mentioned development build of java. – RedCrafter LP Jul 04 '22 at 19:56
  • I didn't install it, I just downloaded the compressed package from the link you provided, unzipped it and put it in the folder shown in the figure. Maybe you can try putting the entire unzipped folder in the `C:\Program Files` directory as I did. (Because I tried to put the Java14 unzipped folder in the root directory of the `C` drive, then VS Code did not recognize it) – JialeDu Jul 05 '22 at 06:36
  • That could be it, because my java jdks are stored in root C because of another program failing at spaces in the jdk path. (I know 2022 and we still have spaced path issues ) – RedCrafter LP Jul 05 '22 at 11:03