Java Configuration in VS Code - Linux Mint

149 Views Asked by At

I really need your help: I can't install and configure Java in VS Code, on Linux Mint.

I've looked for videos, tutorials and the like, but without success. I've already edited /etc/bash.bashrc, /etc/enviroment and finally, my last configuration attempt was /etc/profile, where I included:

JAVA_HOME=/usr/lib/jvm/java-18-openjdk-amd64/
PATH=$JAVA_HOME/bin:$PATH export PATH JAVA_HOME
CLASSPATH=$JAVA_HOME/lib/tools.jar
CLASSPATH=.:$CLASSPATH
export JAVA_HOME PATH CLASSPATH

However, when I try to run a Run and Debug in VS Code, the return I get is just this:

enter image description here

This way, I can't run something in Java in VS Code.

1

There are 1 best solutions below

0
JialeDu On

The error prompts that the jdk path you set is wrong. Please set it to the root directory of the java installation path. (At least JDK 17 version is required).

Specifies the folder path to the JDK (17 or more recent) used to launch the Java Language Server. This setting will replace the Java extension's embedded JRE to start the Java Language Server.

On Windows, backslashes must be escaped, i.e.

"java.jdt.ls.java.home":"C:\Program Files\Java\jdk-17.0_3"

Also you are using Code Runner to execute the program, which may throw an error. Please use the official Java extension package to execute the program.

enter image description here