My area of expertise is not Java. I develop in other languages on other platforms.
Right now I’m developing a series of Java servlets for a project. The servlets are to run on a CentOS server running FileNetP8.
I actually got all of the planned items finished and running.
Now when I am trying to add a few more services, the library I came across is available via Maven. I have no idea what Maven is. Read up on it today. Created a test project to try it out.
My development environment is Eclipse Photon on Windows 10.
Now my problem is I can’t figure out how to add the Filenet JARs to the project. I can’t upload them to some Maven repo. Searching the Web says to add them to the local repo, but I don’t understand how to do that to the Local repo in Eclipse’s builtin Maven.
I think that the JARs don’t need to be packaged within the deployment WAR because the app will be deployed to the Websphere server that runs Filenet so they should be available on it. Should I add them as external JAR references to get the project to compile?
4
Answers
Dependencies need to be added in pom.xml under dependencies tag. Maven will download the specified jars from maven central repository for the first time, and it will be saved in your local repo.
If the dependencies are not available in central repo and if they have their own repo, you to need specify it in the repositories tag.
Any change in the pom.xml, maven will automatically download it.
If the jars are available in Maven Central repo then all you hvae to do is add dependency under dependencies section in your pom.xml file. Set the scope as required, like you said jars don’t needed to be packaged in WAR file as they might be available on server then you can set scope to provided.
If jars are not available in central repo and you want to install them on your local repo then below command should help you. More information here.
I provide below the following approaches to check based upon your suitability.
Approach-1: Install manually
If you have only 1 jar file, execute the following command by replacing as per your requirements.
Once it is done, use the following in your project pom.xml in the dependency section.
The downside of the above approach is, only you can use it as it installs in your .m2 directory. For other developers, they have to follow the same approach. It is not a suggested approach.
Approach-2: Manually add the location of jar file
Add the following dependency in pom.xml
The downside of the above approach is, you have to put all the jar files in a directory and you have to provide the path. All the jar files should be part of your project, it means all the jar file should be put in source code repository. Although it servers the purposes, still it is not a good approach. If you got a newer/higher version of jar file, again you have to put it inside your lib directory. It means you have manage all the old and new versions of jar files.
Best Approach
Maintain Nexus or Artifactory, or any artifactory management system in the organisation and put all the jar files and provide the definition of your custom jar file. It will provide you pom definition. Based upon this, you have to add the dependencies in your project pom.xml. Here you can maintain n number version of your custom jar files.
Seeing as every answer involves maven i’ll try to provide a different and somewhat old school approach. You could always import your jars directly into your project by right clicking on it -> properties -> Add Jars. Apply when done and Voilà. This is far easier than understanding the complexity of maven.