Answer the question
In order to leave comments, you need to log in
How to properly configure build.gradle file to run javafx application?
I am trying to create an executable javafx application without using the javafx plugin.
plugins {
id 'application'
}
repositories {
mavenCentral()
flatDir{
dirs 'C:/Users/insec/Desktop/javafx-sdk-17.0.1/lib'
}
}
dependencies{
implementation files ('javafx.base.jar')
implementation files ('javafx.controls.jar')
}
application {
mainModule = 'piglet.friend'
mainClass = 'piglet.friend.Main'
}
ext.moduleName = 'piglet.friend'
String modulePath = 'C:\\Users\\insec\\Desktop\\javafx-sdk-17.0.1\\lib'
compileJava {
sourceCompatibility = '17'
targetCompatibility = '17'
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', modulePath,
'--add-modules', 'javafx.controls'
]
classpath = files()
}
}
plugins.withType(JavaPlugin).configureEach {
java {
modularity.inferModulePath = true
}
}
run {
/* inputs.property("moduleName", moduleName)*/
doFirst {
jvmArgs = [
'--module-path', modulePath,
'--add-modules', 'javafx.controls'
]
}
}
jar {
manifest {
attributes 'Main-Class': 'piglet.friend.Main'
}
}
java -jar --module-path C:\Users\insec\Desktop\javafx-sdk-17.0.1\lib --add-modules javafx.controls piglet.jar
C:\Program Files\Java\jdk-17.0.1\bin\java.exe --module-path C:\Users\insec\Desktop\javafx-sdk-17.0.1\lib --add-modules javafx.controls -Dfile.encoding=windows-1251 -Duser.country=RU -Duser.language=ru -Duser.variant --module-path C:\Users\insec\Desktop\piglet\build\libs\piglet.jar --module piglet.friend/piglet.friend.Main
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\insec\Desktop\piglet\build\libs\piglet.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Package piglet not found in module
:run (Thread[Execution worker for ':',5,main]) completed. Took 0.078 secs.
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
module piglet.friend{
requires javafx.controls;
requires com.google.gson;
opens piglet;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question