CodePudding user response:
Basically speaking, java extension looks for jars from Referenced Libraries.
Here're my answers to your questions:
Right click the jar and choose
copy relative paththen add it to settings, click the refresh button then the added jar should be displayed under the option Referenced Libraries:The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes. When it comes to add jars, settings
java.project.referencedLibrarieswins.No way to select jar folders but you can use keyboard shortcuts to select all jars then add them.
There's a setting called
"java.configuration.checkProjectSettingsExclusions", and it's true by default, so.projectand.classpathwon't be shown in VS Code.The command Java: Configure Classpath works on my machine, which can customize current project.

My guess is when you open a new project, vscode popped up a window and ask you if trust it, and you chose Not, then project is read-only. Trusting the workspace then try the command Java: Configure Classpath again, it should be writeable.
CodePudding user response:
The answer by @Molly Want-MSFT helped me a lot. Following is what I did to resolve the problem for good. I applied the steps below many time to verify they will work every time.
Steps to open a Java Project in both Eclipse and vscode:
Download the JDK needed for vscode, Eclipse and your Java Project.
Import the project in Eclipse and setup the JDK for the workspace and the project. Also, make sure to setup the compile level to match the JDK.
Set up the Project JDK to match the default of the workspace.
Build the project (Project-Cleanup) and Export the JAR to make sure all is OK.
Now open the project in vscode.
Setup
java.homein Settings, in user and workspace sections. This must be JDK-11 or higher to allow vscode to function properly for Java Projects.Add references to the installed JDKs in User's
settings.jsonunder"java.configuration.runtimes"section.Restart vscode and take the option
Configure Java RuntimefromJAVA PROJECTSview. Make sure that the JDK of the Java Project is detected and working correctly.You may have to open one of the Java Source Code Files. Wait a bit until it will settle down. Check the Java Build Status progress by clicking the spinning icon in the bottom right. This icon is for
Language Serverand it will turn into an icon that looks like thumbs-up when build/compile is done.Close and open
Configure Java Runtimeto verify that the JDK was detected by vscode.Ensure that both
JRE System LibrariesandReferenced LibrariesunderJAVA PROJECTSview are visible without any errors. Check the Problems view and try to resolve all errors.The
Referenced Librariesshould beRead Onlybecause this project was setup in Eclipse. You can delete the.classpathand.projectfiles and open the project again in vscode, and try to fix the problems by adding libraries using thebutton. When such files are deleted, the project will becomeUnmanaged. Later, you can restore such files.
When the project is unmanaged, you use Configure Java Runtime from JAVA PROJECTS view and you can check the project type. You can change the JDK to one of the installed ones as per the section "java.configuration.runtimes" in the user's setting.json.
If the the
Referenced Librariesis read-only, it has no effect even if you can add libraries into settings.json, but the.classpathfile will win.From
JAVA PROJECTSview, you can use the optionBuild WorkspaceandClean Workspaceto troubleshoot and try to resolve errors.Finally, you can
Export JARfrom the option onJAVA PROJECTSview. This option is not clear and it looks like and arrow pointing to the right|-->.
I hope this helps, and if you have any question, please post a comment and I will try to answer back when possible.


