I would like to use a 3rd party java library in my xpage application. I found some instructions on the Web, how jars can be used. Can anyone tell me what am I doing with Java code, which comes in a simple folder?
I would like to use JsonPath.
I would like to use a 3rd party java library in my xpage application. I found some instructions on the Web, how jars can be used. Can anyone tell me what am I doing with Java code, which comes in a simple folder?
I would like to use JsonPath.
I'd like to preface my answer with "I'm sorry". This sort of thing gets more complicated than it should.
In the simple case of your question - how do I add a source-form Java project to my NSF - it's not too bad. I'd take the tack of creating a new source folder in Project Explorer, say "src-jsonpath" and importing the source from the filesystem. However, in this case, that won't work too well.
The trouble is that JsonPath has a good number of dependencies, which you would ALSO need to track down. It's available in Maven, but, since Designer doesn't know anything about Maven, there are some hoops.
The simplest variant of this technique I found was via https://stackoverflow.com/a/15484858/858171, which suggests a two-step process for downloading the library and its various dependencies without having to create an actual Maven project. It (and I will now) assumes you have Maven set up on your system - if you don't, you can find sort-of-okay instructions on maven.apache.org.
With the other major assumption that you're on or can use a Mac or other Unix-alike system, these two lines should download the libraries to the current directory:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=com.jayway.jsonpath:json-path:2.0.0:jar -DoutputDirectory=.
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=com.jayway.jsonpath:json-path:2.0.0:pom -DoutputDirectory=.
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy-dependencies -f json-path-2.0.0.pom -DoutputDirectory=.
The first line actually retrieves the jar for the JsonPath library. The second then retrieves its pom file (project descriptor) - this file isn't useful for your needs directory, but is needed for the next step. The third line then uses this pom file to download the project's dependencies (and its dependencies' dependencies) to the current directory.
Once you've done this, you'll end up with a pile of jar files that you can then either put into the NSF or (probably better, with this many) onto the filesystem. The best route would be to turn them into an XSP OSGi library, but that's a larger topic that I should blog about eventually.