java - 无法再在 Eclipse 上运行 Maven 安装(找不到tools.jar)

标签 java eclipse maven

我正在 ubuntu 16.04 上工作,我有一个 eclipse 项目,我无法再编译了。每次我尝试时都会出现此错误:

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5:compile (default-compile) on project TwavoxManager: Fatal error compiling: tools.jar not found: /usr/lib/jvm/java-8-openjdk-amd64/jre/../lib/tools.jar -> [Help 1]

首先我可以毫无问题地编译它,但我必须在我的系统上重新安装 java (openJDK8)。

我尝试了此链接 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin (default-compile) on project: Fatal error compiling: tools.jar not found 中的解决方案

但问题是 openJDK8 有 JDK + JRE 对吧? 我完全迷失在这里

编辑:添加 pom.xml:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>cineapps</groupId>
  <artifactId>TwavoxManager</artifactId>
  <packaging>jar</packaging>

  <name>TwavoxManager</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
        <plugins>
            <!-- COMPILER -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <!-- RESOURCES -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <!-- SHADE -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <finalName>TwavoxManager-${project.version}-min</finalName>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>cineapps.TwavoxManager.app.App</mainClass>
                                </transformer>
                            </transformers>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/res</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

  <dependencies>
    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.54</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.miglayout/miglayout-swing -->
<dependency>
    <groupId>com.miglayout</groupId>
    <artifactId>miglayout-swing</artifactId>
    <version>4.2</version>
</dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-net</groupId>
        <artifactId>commons-net</artifactId>
        <version>3.3</version>
    </dependency>
  </dependencies>
  <version>1.0</version>
</project>

编辑:有用的屏幕:

enter image description here

最佳答案

更新 pom.xml 中的插件条目,

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

并配置项目 JDK,

右键单击您的项目,“构建路径”->“配置构建路径”。在右侧选项中选择“JRE System Library”选择编辑,然后配置您的JDK

关于java - 无法再在 Eclipse 上运行 Maven 安装(找不到tools.jar),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45077623/

相关文章:

java - Java 中的继承 - "Cannot find symbol constructor"

java - "transient"构建或触发特定构建器

java - 在部署到远程存储库之前运行 Maven 插件

java - 无法将本地 jar 加载到我的 jar 中

java - spinner.setAdapter() 中的 NullPointerException

java - 在 Java 应用程序中保存和更新配置设置

java - 如何阻止 Eclipse 调试我们的库代码

android - 当我安装我的 apk 时,我得到了项目中每个类的图标

java.lang.NoClassDefFoundError : org/apache/taglibs/standard/tag/rt/core/ImportTag 错误

maven - 在配置文件 Maven 中更改源目录