javafx模块javafx.scene.media.AudioClip未找到。

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

javafx module javafx.scene.media.AudioClip not found

问题

我正在为一个使用NetBeans和TMC的课程中的一些学校项目进行工作。我目前正在练习使用JavaFX。到目前为止,JavaFX一直运行良好。我正在尝试导入"javafx.scene.media.AudioClips;",但它显示包"javafx.scene.media"不存在。
如果我尝试构建项目,我会得到以下错误信息:

<!-- language: none -->

org.apache.maven.lifecycle.LifecycleExecutionException: 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile),项目 Osa14_08.Hurraa: 编译失败
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:185)
	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:181)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: 编译失败
	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1215)
	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:188)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 11 more

我已尝试寻找解决方案(将内容添加到pom,下载JavaFX并将其添加到JDK),但都没有奏效。我认为在找到并执行任何解决方案时的问题在于我对这些事物如何工作的理解程度。

英文:

I'm working on some school projects for a class on NetBeans with TMC. I'm at a point where I'm practicing the use of javafx. Javafx has worked without a hitch until now. I'm trying to "import javafx.scene.media.AudioClips;" and it says the package "javafx.scene.media" does not exist.
If I try to build the project I get these error messages:

<!-- language: none -->

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project Osa14_08.Hurraa: Compilation failure
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:185)
	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:181)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1215)
	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:188)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 11 more

I have tried to find solutions for this (adding things to pom, download javafx and add it to the JDK), but none have worked. I'm thinking the problem in finding and executing any solution is my level of understanding how these things work.

答案1

得分: 5

我也在参加赫尔辛基的Java MOOC课程,并且遇到了相同的问题。

在你的 pom.xml 文件中找到类似这样的依赖项,

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11.0.2</version>
</dependency>

然后在它下面添加一个新的依赖项。

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-media</artifactId>
    <version>11.0.2</version>
</dependency>

确保版本号与 javafx-controls 依赖项的版本号相同。

英文:

I am taking the Helsinki Java MOOC course too and ran into the same problem.

In your pom.xml file find the dependency that looks like this,

&lt;dependency&gt;
    &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
    &lt;artifactId&gt;javafx-controls&lt;/artifactId&gt;
    &lt;version&gt;11.0.2&lt;/version&gt;
&lt;/dependency&gt;

then add a new dependency under it .

&lt;dependency&gt;
    &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
    &lt;artifactId&gt;javafx-media&lt;/artifactId&gt;
    &lt;version&gt;11.0.2&lt;/version&gt;
&lt;/dependency&gt;

Make sure the version number is the same as the javafx-controls dependency version.

huangapple
  • 本文由 发表于 2020年5月3日 22:33:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/61576186.html
匿名

发表评论

匿名网友

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

确定