1

我尝试通过 maven 下载 Oracle (Sun) Java JDK,但没有成功:

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

我应该使用什么 Maven 存储库来下载 Oracle (Sun) Java JDK?

添加

我想找到一种方法通过maven下载jdk-6u45-linux-i586.bin JDK安装程序的DLJ版本,而无需手动下载。

现在,当依赖项配置不正确或缺少 maven 存储库时,我会遇到标准 maven 错误:

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
4

3 回答 3

3

如何通过maven下载JDK安装程序?

你不能。JDK 安装程序不在任何公共 Maven 存储库中。如果是这样,甲骨文的律师将发送“停止和终止”信函。

我知道您可以使用 Maven exec 插件(或类似插件)来“解决”Oracle 的点击许可协议。但是,根据美国法律,这可以说是非法的。考虑一下当检察官决定以他为榜样时,“weev”发生了什么。

于 2013-08-06T05:25:10.883 回答
3

当您在 linux 机器上运行时,您可以使用 maven-exec-plugin 调用 curl/wget 下载 jdk:

...
<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>
...
于 2013-08-06T06:36:57.477 回答
0

我开发了maven 插件,它可以从不同的提供商(Liberica、Adopt、SapMachine)下载和解压 OpenJDK,它对于在分发中准备跨平台 JDK 映像很有用

<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>

于 2019-01-30T06:27:49.287 回答