简体   繁体   中英

Cannot find 'tools.jar' on ubuntu 18.04 when using maven

I tried building a custom Jenkins-Plugin using Maven. Here is the issue:

My project depends on org.kohsuke.args4j ( https://github.com/kohsuke/args4j ). I've added the dependency in my pom.xml-file.

  <dependencies>
    <dependency>
      <groupId>org.kohsuke.metainf-services</groupId>
      <artifactId>metainf-services</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>org.kohsuke.args4j</groupId>
      <artifactId>args4j-maven-plugin</artifactId>
      <version>2.33</version>
    </dependency>
  </dependencies>  

The Problem

Apparently, this project requires somehow the tools.jar executable - which cannot be found.

[ERROR] Failed to execute goal on project commit-pipeline-xml: Could not resolve dependencies for project com.siemens.plugins:commit-pipeline-xml:hpi:0.1: Could not find artifact jdk:tools:jar:5.0 at specified path /usr/local/java/jdk-14.0.2/../lib/tools.jar

For my installation (see next paragraph) the path is wrong anyways, but I cannot even find tools.jar in /usr/local/java/jdk-14.0.2/lib/tools.jar where I would expect this file. A ls -l on $JAVA_HOME/lib outputs some files (mostly *.so) but no tools.jar . Also find $JAVA_HOME -name "tools" exposes nothing.


Installation of the jdk

For building my project the I'm using docker with ubuntu 18.04 as base. The jdk gets installed by downloading the tar.gz from oracle.com and installing it using the commands:


mkdir -p /usr/local/java
cd /usr/local/java
tar xzvf "$JAVA_JDK_PATH"
ls -l ./jdk-$JAVA_JDK_VERSION/bin
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk-$JAVA_JDK_VERSION/bin/java" 1 
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk-$JAVA_JDK_VERSION/bin/javac" 1
sudo update-alternatives --set javac "/usr/local/java/jdk-$JAVA_JDK_VERSION/bin/javac"
ls -ld /usr/bin/java*
ls -ld /etc/alternatives/java*

$JAVA_JDK_PATH denotes the path of the downloaded zip-file and $JAVA_JDK_VERSION the jdk-version to download.

Note: I assume the installation works, since I can typically build other maven projects.

How to I install the jdk in order to get the tools.jar file?

Apparently, this is not possible any more since JDK9, according to @Hans and this post .

Closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM