Issue
I'm trying to create javafx media player as gradle project, but got this error.error: package javafx.scene.media does not exist on line: import javafx.scene.media.Media;
Here is my build.gradle
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
group 'life.antonov'
version '1.0'
mainClassName='life.antonov.muza.Main'
sourceCompatibility = 11
jar {
manifest {
attributes "Main-Class": "$mainClassName"
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
javafx {
version = "13"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.openjfx', name: 'javafx-controls', version: '13'
compile group: 'org.openjfx', name: 'javafx-fxml', version: '13 '
compile group: 'org.openjfx', name: 'javafx-media', version: '13'
}
I'm tried to unzip downloaded javafx-media jar file and it is almost empty:
$ unzip javafx-media-13.jar
Archive: javafx-media-13.jar
creating: META-INF/
inflating: META-INF/MANIFEST.MF
Why? Maybe I wrote wrong dependencies? What I have to do to make my application compile and work?
Solution
I have not tested it, but:
Replace:
modules = [ 'javafx.controls', 'javafx.fxml' ]
With
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.media' ]
Answered By - MelvinWM
Answer Checked By - David Marino (JavaFixing Volunteer)