2

I created my first Azure Function in Java because I would need to use a specific external jar file. I am working in VS Code and I have found a short reference in the docs on using external libraries. Third-party libraries.

However I don't get the import to work. It would be great to have an example of a VS Code Java Azure Functions project using external libraries or a more detailed step by step documentation.

donquijote
  • 1,642
  • 5
  • 19
  • 41
  • 1
    checkout this repo for sample: https://github.com/yoshioterada/Azure-Functions-For-Java-Sample – Ketan Mar 04 '19 at 16:56
  • @KetanChawda-MSFT thank you very much. I am working with VS Code using the Azure Functions extension and Java Extension Pack. I tried to follow the first step in your reference but I don't seem to be able to install the jar file I need to work with. I have no prior experience with java projects or maven. Do you have an even more basic reference? Do you know if there is a way to add the jar reference with the tooling in VS Code? – donquijote Mar 04 '19 at 17:37
  • 1
    In a maven project, all the dependencies are handled by pom.xml. We can use either maven repositories to download the dependencies or you can add it from your local directory. The following can be done install jar to local maven repository. Checkout this link for reference : http://maven.apache.org/general.html#importing-jars – Ketan Mar 05 '19 at 05:06
  • 1
    also checkout this SO post : https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project/36602256#36602256 – Ketan Mar 05 '19 at 05:13

1 Answers1

1

In a maven project, all the dependencies are handled by pom.xml. We can use either maven repositories to download the dependencies or you can add it from your local directory. The following can be done install jar to local maven repository.

References: http://maven.apache.org/general.html#importing-jars https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

mvn install:install-file
  -Dfile=<path-to-file>
  -DgroupId=<group-id>
  -DartifactId=<artifact-id>
  -Dversion=<version>
  -Dpackaging=<packaging>
  -DgeneratePom=true

Where: <path-to-file>  the path to the file to load
       <group-id>      the group that the file should be registered under
       <artifact-id>   the artifact name for the file
       <version>       the version of the file
       <packaging>     the packaging of the file e.g. jar
Ketan
  • 1,530
  • 7
  • 16