JavaFX Maven执行目标失败。

huangapple go评论70阅读模式
英文:

JavaFX Maven failed to execute goal

问题

这是我的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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.Jan.Raspberry.Shell</groupId>
    <artifactId>RaspberryShell</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
            <version>0.1.55</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>14</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>14</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.1</version>
                <configuration>
                    <executable>C:\Program Files\Java\jdk-11.0.6\bin\java</executable>
                    <mainClass>de.Jan.Raspberry.Shell.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是完整的错误信息:

[INFO] 
[INFO] ---------------< de.Jan.Raspberry.Shell:RaspberryShell >---------------
[INFO] Building RaspberryShell 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.1:run (default-cli) @ RaspberryShell ---
[WARNING] Required filename-based automodules detected. Please don't publish this project to a public artifact repository!
[ERROR] Command execution failed.
java.io.IOException: Cannot run program "C:\Program Files\Java\jdk-11.0.6\bin\java" (in directory "C:\Users\jan\Desktop\Programmieren\Java\Other\RaspberryShell\RaspberryShell\RaspberryShell"): CreateProcess error=5, Access is denied
...

如果你遇到了问题,请检查可执行文件路径和文件权限。

英文:

I recentely created my JavaFX Maven Project with IntelliJ and JDK-11. But If I run mvn javafx:run I get this error:

> Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.1:run
> (default-cli) on project RaspberryShell: Error

I really searched the whole internet and found nothing. Any ideas?

This is my pom.xml:

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;de.Jan.Raspberry.Shell&lt;/groupId&gt;
    &lt;artifactId&gt;RaspberryShell&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;
        &lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.jcraft&lt;/groupId&gt;
            &lt;artifactId&gt;jsch&lt;/artifactId&gt;
            &lt;version&gt;0.1.55&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-controls&lt;/artifactId&gt;
            &lt;version&gt;14&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-fxml&lt;/artifactId&gt;
            &lt;version&gt;14&lt;/version&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                &lt;version&gt;3.8.0&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;release&gt;11&lt;/release&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
                &lt;artifactId&gt;javafx-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;0.0.1&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;executable&gt;C:\Program Files\Java\jdk-11.0.6&lt;/executable&gt;
                    &lt;mainClass&gt;de.Jan.Raspberry.Shell.Main&lt;/mainClass&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
&lt;/project&gt;

Edit:
This is the full error:

[INFO] 
[INFO] ---------------&lt; de.Jan.Raspberry.Shell:RaspberryShell &gt;----------------
[INFO] Building RaspberryShell 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.1:run (default-cli) @ RaspberryShell ---
[WARNING] Required filename-based automodules detected. Please don&#39;t publish this project to a public artifact repository!
[ERROR] Command execution failed.
java.io.IOException: Cannot run program &quot;C:\Program Files\Java\jdk-11.0.6&quot; (in directory &quot;C:\Users\jan\Desktop\Programmieren\Java\Other\RaspberryShell\RaspberryShell\RaspberryShell&quot;): CreateProcess error=5, Access is denied
    at java.lang.ProcessBuilder.start (ProcessBuilder.java:1128)
    at java.lang.ProcessBuilder.start (ProcessBuilder.java:1071)
    at java.lang.Runtime.exec (Runtime.java:589)
    at org.apache.commons.exec.launcher.Java13CommandLauncher.exec (Java13CommandLauncher.java:61)
    at org.apache.commons.exec.DefaultExecutor.launch (DefaultExecutor.java:279)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:336)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.openjfx.JavaFXRunMojo.executeCommandLine (JavaFXRunMojo.java:525)
    at org.openjfx.JavaFXRunMojo.executeCommandLine (JavaFXRunMojo.java:487)
    at org.openjfx.JavaFXRunMojo.execute (JavaFXRunMojo.java:168)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
    at java.lang.ProcessImpl.create (Native Method)
    at java.lang.ProcessImpl.&lt;init&gt; (ProcessImpl.java:478)
    at java.lang.ProcessImpl.start (ProcessImpl.java:154)
    at java.lang.ProcessBuilder.start (ProcessBuilder.java:1107)
    at java.lang.ProcessBuilder.start (ProcessBuilder.java:1071)
    at java.lang.Runtime.exec (Runtime.java:589)
    at org.apache.commons.exec.launcher.Java13CommandLauncher.exec (Java13CommandLauncher.java:61)
    at org.apache.commons.exec.DefaultExecutor.launch (DefaultExecutor.java:279)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:336)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.openjfx.JavaFXRunMojo.executeCommandLine (JavaFXRunMojo.java:525)
    at org.openjfx.JavaFXRunMojo.executeCommandLine (JavaFXRunMojo.java:487)
    at org.openjfx.JavaFXRunMojo.execute (JavaFXRunMojo.java:168)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

答案1

得分: 2

让我们一起查看你的日志。你被告知:

java.io.IOException:无法运行程序“C:\Program Files\Java\jdk-11.0.6”(在目录“C:\Users\jan\Desktop\Programmieren\Java\Other\RaspberryShell\RaspberryShell\RaspberryShell”中):CreateProcess错误=5,拒绝访问

随后引发:

Caused by:java.io.IOException:CreateProcess错误=5,拒绝访问

error=5通常意味着你要么:

  1. 对可执行文件的路径有误;(顺便问一下,"C:\Program Files\Java\jdk-11.0.6" 是可执行文件的路径吗?我认为不是)
  2. 没有权限读取(运行)该文件。

你必须确保可执行文件的路径正确,并且你对它具有适当(必要的)访问权限。

英文:

Let's check your log together. You're told, that:

java.io.IOException: Cannot run program &quot;C:\Program Files\Java\jdk-11.0.6&quot; (in directory &quot;C:\Users\jan\Desktop\Programmieren\Java\Other\RaspberryShell\RaspberryShell\RaspberryShell&quot;): CreateProcess error=5, Access is denied

which then causes:

Caused by: java.io.IOException: CreateProcess error=5, Access is denied

error=5 usually means, that you either:

  1. have a wrong path to the executable file; (by the way, is "C:\Program Files\Java\jdk-11.0.6" path to the executable? I don't think so)
  2. have no permission to read(run) that file.

You have to make sure your path to the executable file is correct, and that you have an appropriate (required) access to it.

huangapple
  • 本文由 发表于 2020年7月26日 06:42:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63094312.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定