• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

javafx.scene.media does not exist

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm hoping to create an audio playing program using AudioClip.  However when I try to import import javafx.scene.media.AudioClip I get an error message saying package javafx.scene.media does not exist.  Can you advise me what to do next please?
 
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add a dependency on javafx-media to your project. If you are using Maven, you can do it like this:
 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to add the code,  I got an error message:

class, interface, enum  or record expected
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try to add the XML snippet I wrote to a Java source file? That won't work. It was intended to be added to a pom.xml file, IF your project is being built using Maven.

How did you add the other JavaFX libraries to your project?
 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I tried to add to add it to the source file.  I am using an IDE called Apache Netbeans. When I started the project I selected an option called Java with Maven.

To add the other JavaFX libraries I simply wrote 'import javafx.scene.media.Media;'
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well then, the main folder of your project should contain a pom.xml file. Show it to us.
 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was the javafx-media dependency already in that file, or did you add it in after I told you to?

What happens when you right-click your project and select "Clean and Build"?
 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added the dependency after you told me to.

When I select clean and build I get the following:

cd C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest; "JAVA_HOME=C:\\Program Files\\Java\\jdk-18.0.2.1" cmd /c "\"C:\\Program Files\\NetBeans-14\\netbeans\\java\\maven\\bin\\mvn.cmd\" \"-Dmaven.ext.class.path=C:\\Program Files\\NetBeans-14\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" clean install"
Scanning for projects...

-----------------< com.mycompany.soundtest:SoundTest >------------------
Building SoundTest 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------

--- maven-clean-plugin:2.5:clean (default-clean) @ SoundTest ---
Deleting C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest\target

--- maven-resources-plugin:2.6:resources (default-resources) @ SoundTest ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest\src\main\resources

--- maven-compiler-plugin:3.1:compile (default-compile) @ SoundTest ---
Changes detected - recompiling the module!
Compiling 1 source file to C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest\target\classes

--- maven-resources-plugin:2.6:testResources (default-testResources) @ SoundTest ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest\src\test\resources

--- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SoundTest ---
No sources to compile

--- maven-surefire-plugin:2.12.4:test (default-test) @ SoundTest ---
No tests to run.

--- maven-jar-plugin:2.4:jar (default-jar) @ SoundTest ---
Building jar: C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest\target\SoundTest-1.0-SNAPSHOT.jar

--- maven-install-plugin:2.4:install (default-install) @ SoundTest ---
Installing C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest\target\SoundTest-1.0-SNAPSHOT.jar to C:\Users\montk\.m2\repository\com\mycompany\soundtest\SoundTest\1.0-SNAPSHOT\SoundTest-1.0-SNAPSHOT.jar
Installing C:\Users\montk\OneDrive\Documents\NetBeansProjects\SoundTest\pom.xml to C:\Users\montk\.m2\repository\com\mycompany\soundtest\SoundTest\1.0-SNAPSHOT\SoundTest-1.0-SNAPSHOT.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time:  0.864 s
Finished at: 2022-12-14T20:52:55Z
------------------------------------------------------------------------
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then... is your issue resolved?
 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that the issue has been resolved.

Can you tell me whether the method Audioclip I was trying to use is a method from java applets which are no longer being used? (I apologise if I am using the wrong terminology).
 
Sheriff
Posts: 28331
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There was a java.applet.AudioClip in Java -- there still is, technically, but it's deprecated and going to be removed.

And there's a javafx.scene.media.AudioClip class in JavaFX.

Presumably they are for the same purpose, but if you're coding in JavaFX then you'll want to use the JavaFX version.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello, I have the same issue, how to clean and build in intellij?
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

From the Maven tool window, run the "clean" and "verify" lifecycle phases.

If you need more help, share with us the exact error message you are getting, and your pom.xml.
 
Replace the word "snake" with "danger noodle" in all tiny ads.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic