Question

I try to download Oracle (Sun) Java JDK via maven without success:

<dependency>
    <groupId>com.sun</groupId>
    <artifactId>jdk</artifactId>
    <version>6u45</version>
    <classifier>dlj-linux-i586</classifier>
    <type>bin</type>
</dependency>

What maven repository should I use to download Oracle (Sun) Java JDK?

Added

I want to find a way to download DLJ version of jdk-6u45-linux-i586.bin JDK installer by maven, without manually download.

Now i have standard maven error when dependency is not configured well or a maven repository is missed:

Missing:
----------
com.sun:jdk:bin:dlj-linux-amd64:6u45

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=com.sun -DartifactId=jdk -Dversion=6u45 -Dclassifier=dlj-linux-amd64 -Dpackaging=bin -Dfile=/path/to/file
Was it helpful?

Solution

How to download JDK installer by maven?

You can't. The JDK installer is not in any public Maven repository. If it was, the Oracle lawyers would be sending "cease and desist" letters.

I am aware that you could use the Maven exec plugin (or similar) to "work around" Oracle's click through license agreement. However, this is arguably illegal under US law. Consider what happened to "weev" when prosecutors decided to make an example of him.

OTHER TIPS

When you're running on a linux machine, you can download the jdk using maven-exec-plugin calling curl/wget :

...
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <executions>
    <!-- using curl -->
    <execution>
      <id>download oracle jdk (curl)</id>
      <phase>process-resources</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>curl</executable>
        <arguments>
          <argument>-L</argument>
          <argument>--header</argument>
          <argument>Cookie: s_nr=1359635827494; s_cc=true; gpw_e24=blub; s_sq=[[]]; gpv_p24=novalue</argument>
          <argument>http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin</argument>
          <argumen>-o</argumen>
          <argument>${project.build.directory}/curl-jdk-6u45-linux-i586.bin</argument>
        </arguments>
      </configuration>
    </execution>
    <execution>
      <!-- using wget -->
      <id>download oracle jdk (wget)</id>
      <phase>process-resources</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>wget</executable>
        <arguments>
          <argument>--no-cookies</argument>
          <argument>--header</argument>
          <argument>Cookie: s_nr=1359635827494; s_cc=true; gpw_e24=blub; s_sq=[[]]; gpv_p24=no value</argument>
          <argument>http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin</argument>
          <argument>-O</argument>
          <argument>${project.build.directory}/wget-jdk-6u45-linux-x64.bin</argument>
        </arguments>
      </configuration>
    </execution>
  </executions>
</plugin>
...

I have developed maven plugin which can download and unpack OpenJDK from different providers (Liberica, Adopt, SapMachine), it is useful for preparing cross-platform JDK images in distributives

<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>mvn-jlink-wrapper</artifactId>
<version>1.0.2</version>
<executions>
    <execution>
        <id>cache-jdk-8</id>
        <goals>
            <goal>cache-jdk</goal>
        </goals>
        <configuration>
            <jdkPathProperty>jlink.jdk.path</jdkPathProperty>
            <jdkCachePath>${project.build.directory}${file.separator}jdkCache</jdkCachePath>

            <provider>ADOPT</provider>
            <providerConfig>
                <release>jdk8u192-b12</release>
                <arch>x64</arch>
                <type>jdk</type>
                <impl>hotspot</impl>
            </providerConfig>

        </configuration>
    </execution>
</executions>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top