You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support to add Jar file or any other file/directory to classpath #94
I'm somewhat of a noob to this, but it seems quite odd to me that this is so difficult. Stackoverflow suggests a solution, but that doesn't work for me. I've tried both absolute and relative referencing of the jar file, putting the .classpath file in various locations, but it seems that vscode ignores it entirely. Any suggestions will be appreciated :) (I'd prefer a solution that works with the vanilla javac, e.g. without having to install maven)
Reacted by Harald Fernengel, Greg Greenleaf, Seong-June Kim, Vint Prox, Omar Hussain and jmechevarria
It's so easy, anyway:
0. Creat project with java ctrl+shift+p
add the jar file to your .classpath
add on the top of your project package [app]; the name of your package
We are done, don't forget to refresh it.
Reacted by Tom Arbuz, Timur Fayzrakhmanov, amritha014, Nicholas Ruppel, Gabriel Moncau, A, masooria, Roshan Parajuli, github9604, peterrmah and 10 more
Start from Language Support for Java@0.55.0, we added a new setting java.project.referencedLibraries to config the project classpaths. Please see this link for usage guide.
Meanwhile, in order to improve the UX, we had this PR to let the users be able to config this setting from the Dependency Explorer, which will be available in the next version of Java Dependency Viewer:
Close this issue for now, but please feel free to let us know if you have any thoughts on this.
Thanks.
Reacted by Miguel Figueira, jmechevarria, Florian Rascoussier, nieg675, Tuan Ho and jihadmahdi
Start from Language Support for Java@0.55.0, we added a new setting java.project.referencedLibraries to config the project classpaths. Please see this link for usage guide.
Meanwhile, in order to improve the UX, we had this PR to let the users be able to config this setting from the Dependency Explorer, which will be available in the next version of Java Dependency Viewer:
Close this issue for now, but please feel free to let us know if you have any thoughts on this.
Thanks.
java.project.refe.. libs in mac os is not working. it is not a multiroot project, etc all java dependencies installed. thanks
thanks guys for responding. it is an https://ant.apache.org/ivy/ivyde/ project. yes .classpath and .projects are there, what is not resolving in .classpath is ref's like this.
i could add the jar's individually as <classpathentry kind="lib" path="absolute path to a jar"....> but that would not be the ideal way.
there is a plugin (https://archive.codeplex.com/?p=ivyvisual) but it is not in .vscode market place
I see. Just as you said, some of the classpathentries needs to be resolved by the specific IvyDE plugin, while this plugin is not support VS Code right now. So I'm afraid you have to use the workaround you have mentioned right now.
Hi, I'm trying too to use referencedLibraries to include libraries, but it doesn't work... no effect at all and I work on windows 10.
I see also that using java dependency you can add external lib with the interface, (using the add button in the corner). I haven't the button, and folders are labeled with (Read-only).
By now the only way I can add external lib is to typing directly the classpath file.
WIth eclipse, no problem to add libs in the same project.
I've been having issues with incorporating .jar files from an external library into my project on vscode. The project was standalone and was not made through a "create Java app" function, so my directory does not contain an .classpath files. However, I was able to add the necessary .jar files to a lib file as well as have the Java Dependency View recognize the two .jar files I wanted to add.
However, when I try to compile a file that imports one of these files, I keep getting compiler errors saying that the package does not exist. Any idea as to what the issue could be? Here are a few pictures of the jar files located in my directory:
Start from Language Support for Java@0.55.0, we added a new setting java.project.referencedLibraries to config the project classpaths. Please see this link for usage guide.
Meanwhile, in order to improve the UX, we had this PR to let the users be able to config this setting from the Dependency Explorer, which will be available in the next version of Java Dependency Viewer:
Close this issue for now, but please feel free to let us know if you have any thoughts on this.
HuskyNator we recommend to directly update the pom file, since that is the source of the truth of what the project build process. (otherwise, the build result in VS Code might be different from that in CI/CD).
BTW, we do have the same request here. Please feel free to upvote it. If more and more people are requesting for it. We will consider to support this feature.
i'm not sure i'm in the right place but i have been searching for days how to handle the eclipse project USER_LIBRARYS i have.
My project is a Eclipse project with the .classpath and .project visible in vscode, my coworkers all use Eclipse and they have those two files in version control, so i can't delete or modify it (at least i can't delete entry in the .classpath).
and the Java project window show me all the entry like this :
The JRE.CONTAINER is found and all the libs are ok for this one, but all the others are totaly empty ( should have about 80 libs in those ).
As the project is "managed" the use of "java.project.referencedLibraries" doesn't work and i can't add the jar manually either since everything is readOnly in the "Configure Classpath"
I'm sorry for digging this up but i'm really lost on this..
Is it just not supported and i have to use eclipse, do i need to try to find a way to remove the .classpath and .project of the version control so i can use "java.project.referencedLibraries" or is there a way i make it work in vscode? Or maybe a way to ignore those .classpath and .project so that it is unmanaged and i import all the libs in settings.json ?
I finnaly made it work by changing names of .classpath and .project files, so that it's unmanaged, but then vscode told me it was not a java project anymore.
I had to add this to settings.json
"java.project.sourcePaths": ["."],
Then i just imported all the libraries in the settings.json and it all worked !
The only "problem" i have between this and eclipse is that the order in which you declare your imports doesn't seem to have an impact on which lib is used, in the .classpath the first libs are always used over the other one if there is a conflct.
Here i tried to put the one i want to be the default in first or in last but it still use the other one.
I know we shouldn't have conflict but yeah...
Do you think there is a way to do this? Or maybe i need to make a feature-request?
Thanks again for all of this, using eclipse was a nightmare for me !
karter (@kartercs) So far, the unmanaged folder does not have the concept of import order for those referenced libraries. Please file a feature request for that :)
Activity
akaroml commentedon Feb 15, 2019
Yaohai Zheng (@yaohaizh) please help link this issue to vscode-java's new feature of adding Jar dependencies directly.
martinkoch-geniebelt commentedon Aug 15, 2019
I'm somewhat of a noob to this, but it seems quite odd to me that this is so difficult. Stackoverflow suggests a solution, but that doesn't work for me. I've tried both absolute and relative referencing of the jar file, putting the .classpath file in various locations, but it seems that vscode ignores it entirely. Any suggestions will be appreciated :) (I'd prefer a solution that works with the vanilla javac, e.g. without having to install maven)
akaroml commentedon Oct 25, 2019
Vigilans (@Vigilans) please take a look at this issue. Users are looking for a way of adding dependencies to their projects.
nimr77 commentedon Oct 30, 2019
It's so easy, anyway:
0. Creat project with java ctrl+shift+p
akaroml commentedon Dec 3, 2019
We are in the process of adding a UI entry for this. Vigilans (@Vigilans) is on this.
jdneo commentedon Jan 13, 2020
Start from
Language Support for Java@0.55.0, we added a new settingjava.project.referencedLibrariesto config the project classpaths. Please see this link for usage guide.Meanwhile, in order to improve the UX, we had this PR to let the users be able to config this setting from the Dependency Explorer, which will be available in the next version of

Java Dependency Viewer:Close this issue for now, but please feel free to let us know if you have any thoughts on this.
Thanks.
husseinkohy commentedon Mar 13, 2020
java.project.refe.. libs in mac os is not working. it is not a multiroot project, etc all java dependencies installed. thanks
jdneo commentedon Mar 14, 2020
vaanalyst (@husseinkohy) What kind of project are you working on?
Let's say, Can you see files like
.project,.classpathin your project's root path?husseinkohy commentedon Mar 14, 2020
thanks guys for responding. it is an https://ant.apache.org/ivy/ivyde/ project. yes .classpath and .projects are there, what is not resolving in .classpath is ref's like this.
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=....
i could add the jar's individually as <classpathentry kind="lib" path="absolute path to a jar"....> but that would not be the ideal way.
there is a plugin (https://archive.codeplex.com/?p=ivyvisual) but it is not in .vscode market place
jdneo commentedon Mar 15, 2020
I see. Just as you said, some of the classpathentries needs to be resolved by the specific
IvyDEplugin, while this plugin is not support VS Code right now. So I'm afraid you have to use the workaround you have mentioned right now.mp768 commentedon Mar 22, 2020
can you give a tutorial on how to set up through video, because I'm not entirely understanding it.
jdneo commentedon Mar 23, 2020
Michael (@mp768) What kind of project are you using?
brunoborges commentedon Mar 31, 2020
Confirmed: not working on macOS. Tried with a "naked" project.
micheledellaciana1 commentedon Apr 7, 2020
Hi, I'm trying too to use referencedLibraries to include libraries, but it doesn't work... no effect at all and I work on windows 10.
I see also that using java dependency you can add external lib with the interface, (using the add button in the corner). I haven't the button, and folders are labeled with (Read-only).
By now the only way I can add external lib is to typing directly the classpath file.
WIth eclipse, no problem to add libs in the same project.
Thk in advice for help
jdneo commentedon Apr 8, 2020
Michele Della Ciana (@micheledellaciana1) I guess your project is an Eclipse project, which is so far not supported to manage libs in the dependency viewer.
Here, what we supported is the
non-project files/folders, which means, there is no.classpathor.projectin your project base path.micheledellaciana1 commentedon Apr 9, 2020
ahhh Now I get it! Everything works fine! Many thanks! :))
labibhussain commentedon Apr 19, 2020
Is a .classpath file absolutely necessary?
I've been having issues with incorporating .jar files from an external library into my project on vscode. The project was standalone and was not made through a "create Java app" function, so my directory does not contain an .classpath files. However, I was able to add the necessary .jar files to a lib file as well as have the Java Dependency View recognize the two .jar files I wanted to add.
However, when I try to compile a file that imports one of these files, I keep getting compiler errors saying that the package does not exist. Any idea as to what the issue could be? Here are a few pictures of the jar files located in my directory:


gerrywp commentedon Nov 27, 2020
你好,请问怎么引用本地的.class字节码文件夹呢?这里只能添加.jar包,并不能添加一个包含.class文件的包的目录噢!
jdneo commentedon Nov 27, 2020
pai (@gerrywp) It's only supporting jar file right now, please feel free to create new feature requests here if you want more support
HuskyNator commentedon Feb 15, 2021
What about adding it to projects that use maven? Those don't show a "Reference Libraries" section 😞
jdneo commentedon Feb 16, 2021
HuskyNator we recommend to directly update the pom file, since that is the source of the truth of what the project build process. (otherwise, the build result in VS Code might be different from that in CI/CD).
BTW, we do have the same request here. Please feel free to upvote it. If more and more people are requesting for it. We will consider to support this feature.
kartercs commentedon Jul 6, 2022
Hello,
i'm not sure i'm in the right place but i have been searching for days how to handle the eclipse project USER_LIBRARYS i have.
My project is a Eclipse project with the .classpath and .project visible in vscode, my coworkers all use Eclipse and they have those two files in version control, so i can't delete or modify it (at least i can't delete entry in the .classpath).
my classpath file looks like this :
and the Java project window show me all the entry like this :
The JRE.CONTAINER is found and all the libs are ok for this one, but all the others are totaly empty ( should have about 80 libs in those ).
As the project is "managed" the use of "java.project.referencedLibraries" doesn't work and i can't add the jar manually either since everything is readOnly in the "Configure Classpath"
I'm sorry for digging this up but i'm really lost on this..
Is it just not supported and i have to use eclipse, do i need to try to find a way to remove the .classpath and .project of the version control so i can use "java.project.referencedLibraries" or is there a way i make it work in vscode? Or maybe a way to ignore those .classpath and .project so that it is unmanaged and i import all the libs in settings.json ?
jdneo commentedon Jul 7, 2022
karter (@kartercs) AFAIK, USER_LIBRARY is not supported.
Should work in this way. If it does not, please let us know.
kartercs commentedon Jul 7, 2022
Thanks for your answer Sheng Chen (@jdneo) !
I finnaly made it work by changing names of .classpath and .project files, so that it's unmanaged, but then vscode told me it was not a java project anymore.
I had to add this to settings.json
Then i just imported all the libraries in the settings.json and it all worked !
The only "problem" i have between this and eclipse is that the order in which you declare your imports doesn't seem to have an impact on which lib is used, in the .classpath the first libs are always used over the other one if there is a conflct.
Here i tried to put the one i want to be the default in first or in last but it still use the other one.
I know we shouldn't have conflict but yeah...
Do you think there is a way to do this? Or maybe i need to make a feature-request?
Thanks again for all of this, using eclipse was a nightmare for me !
jdneo commentedon Jul 7, 2022
karter (@kartercs) So far, the unmanaged folder does not have the concept of import order for those referenced libraries. Please file a feature request for that :)
kartercs commentedon Jul 7, 2022
Sheng Chen (@jdneo) Thank you so much for your fast reponses !
I just did the feature request if someone need to find it's there #1023