-3

I want to use javafx media library for audiofiles, but making a new Media instance throws InvocationTargetException written in minecraft enchantment table language.

I tried to instantiate it in multiple ways: by passing path.toString(), by passing a file as a string or just hardcoded string. All of them throw the same exception.

new MediaPlayer(new Media(new File(filePath).toURI().toString()));

Where filePath is C:\Users\User\Desktop\folder\java\AudioCutter\target\classes\audioFile.wav

A file or AudioInputStream with the same path works.

JavaFX is imported as a library in Intellij Idea project structure, and it works.

I use java 16.

Samuel
  • 11
  • 2
  • 2
    Please don’t post screenshots of text, instead copy the text into the question and format it as code (there is an icon in the editor for the formatting). – jewelsea Feb 10 '22 at 22:27
  • I've posted screenshot of the exception, because of its unreadable formatting, which could hint at some problem. Copied text is in the title. – Samuel Feb 11 '22 at 12:45

1 Answers1

0

Troubleshooting media exceptions

To get more debugging information, apply the code template for error handling provided in:

Creating a new test project

However, rather than trying to get your current setup to work, I advise creating a new project just to verify the execution of this functionality in your environment.

As you are using Idea, create a new project as outlined in the answer to:

except:

  • add the pom.xml dependency for javafx-media AND
  • adjust the module-info to require javafx.media

Load your media file in the start method of the new project.

About the error message in your question

The extra zeros in the error message are probably a result of a character encoding issue, e.g. processing utf-16 characters as utf-8.

I guess the “Minecraft enchantment table language” was a joke.

I don’t think there is an easy way to pin down the cause of that in this forum. The issue is likely an environmental, configuration or setup issue on your end, or an attempt to use an unsupported or invalid media file format.

Instead, take a different approach using a new project configuration and media files that have been known to work for others and make use of the full debugging source template mentioned earlier.

jewelsea
  • 150,031
  • 14
  • 366
  • 406