1

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
Michael
  • 9,061
  • 16
  • 53
  • 96

3 Answers3

3

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.

Stephen C
  • 632,615
  • 86
  • 730
  • 1,096
  • Thanks. I will not download it via "workaround". I will download it once manually and will redistribute it. I understand that according to Oracle license I can redistribute it: http://www.oracle.com/technetwork/java/javase/downloads/java-se-archive-license-1382604.html. – Michael Aug 06 '13 at 10:35
3

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>
...
Hawky4s
  • 746
  • 6
  • 5
  • 1
    Beware that this is circumventing the scheme that Oracle uses to ensure that you assent to the license terms. Doing this could be construed as accessing a computer system without authorization. People have been prosecuted and sent to prison in the United States for this kind of thing. – Stephen C Aug 06 '13 at 07:58
  • No, they have not. No one has ever come close to being prosecuted for such a thing. Open source packages such as Jenkins automate this all the time. – bmargulies Aug 07 '13 at 23:35
  • @bmargulies - The fact that nobody has been prosecuted yet doesn't mean that they couldn't. It is facially illegal according to the law that "weev" was prosecuted under. (Circumventing the click through is arguably accessing a computer system without authorization.) All it requires is Oracle to complain and an abusive US Federal Prosecutor. Read up on the "weev" case. – Stephen C Aug 09 '13 at 06:22
0

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>

Igor Maznitsa
  • 703
  • 6
  • 11