12

I have a project where I need the JNLP API. I did not find an artifact for that on Maven Central, so I added an external Repository which offers that to my pom. That repository went offline this weekend. This is the second time something like this happened to me.

I know this is pretty much what Maven is not about, but really I just want that tiny jnlp-api-1.5.0.jar file to be

  1. In my SCM (I don't want to roll my own Maven repository for just one dependency).
  2. In the compile scope when the project builds.

Which knobs do I have to turn to accomplish this?

Nathan
  • 8,093
  • 8
  • 50
  • 76
Waldheinz
  • 10,399
  • 3
  • 31
  • 61

2 Answers2

15

As of JDK 7.0, the JNLP API is being provided by the javaws.jar file in your JRE's lib directory, i.e., ${java.home}/lib/javaws.jar. It is possible to use the maven dependency scope system.

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>javax.jnlp</groupId>
      <artifactId>jnlp-api</artifactId>
      <version>7.0</version>
      <scope>system</scope>
      <systemPath>${java.home}/lib/javaws.jar</systemPath>
    </dependency>
  </dependencies>
  ...
</project>
A Lee
  • 7,828
  • 4
  • 35
  • 49
Jcs
  • 13,279
  • 5
  • 53
  • 70
  • 1
    Now I have `${basedir}/src/libs/jnlp-api-1.5.0.jar` and it works like a charm. Even Hudson likes it. Thanks! – Waldheinz Jan 10 '11 at 10:30
  • On mac JDK 1.6 ships the jnlp classes in ${java.home}/lib/javaws.jar. – Kane Feb 21 '13 at 05:45
  • This only seems to work with Oracle JDK. Using a local path like Waldheinz mentions might work for one project, but if that's a dependency of another the path might not be valid any more. – javydreamercsw Nov 18 '16 at 14:27
4

You can put the JAR in your local repository using the install-file goal of the maven-install-plugin and reference it as you normally would in your POM. The command would be:

mvn install:install-file -Dfile=/path/to/jnlp-api-1.5.0.jar -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=1.5.0 -Dpackaging=<packaging>

Place this command in a script and check it into your SCM. That way, you (and anyone else working on this project) can install it easily to the local repo.

dogbane
  • 266,786
  • 75
  • 396
  • 414