Problem: it doesn't let me add external libraries (JARs), I right click where it says "Java Dependencies" and the menu doesn't appear, also when I create another project like java application it only creates the folders that you see in the image and not creates the libraries folder for me.
I would like to know if there is any other way to add libraries to my project other than the one mentioned above...
( NetBeans version: 11.3)
Hello @JPprogramador I explain what happens:
Netbeans 11+ generates by default "Java Application" projects using Maven , which is a technology that helps you with dependency management and project construction, you can see this because in the logo of the java project cup there is a small
m
at the top left, that's why you can't add external libraries manually as according to Maven's philosophy it would be a bad practice.To add libraries there are 2 options:
Project Files
is the filepom.xml
where the dependencies are managed and it would be as follows:As you can see, you must add the node inside
project
the nodedependencies
and inside each dependency of your project that you look for in maven central, the dependency is divided into:groupId: represents the dependency package with which the project was created, multiple libraries can exist under this package.
artifactId: represents the name of the library you will use.
version: represents the version of the library to use in central maven you can see all the available versions.
When you save the change in the
pom
netbeans file, it will download the dependency from the central repository and the library will appear in thedependencies
.All the libraries downloaded with maven can be found in a hidden folder within your user in the path %UserProfile%.m2\repository, if you plan to enter the world of java it is important that you familiarize yourself with Maven or Gladle which are the 2 projects management and construction of major projects.
Using maven is very important because it allows the teams to no longer have to worry about the libraries in the projects, because when importing the project in another pc, maven will take care of downloading the libraries that are not available in your local environment so that you have your project for execution, previously there were problems such as: if you work in a team you had to share the project together with all the libraries and if we add a new library or change the version to a more recent one you had to guarantee that each member working on the project receive a notification to add the new library or update the version of the existing ones.