#Can't use javafx with gradle

1 messages · Page 1 of 1 (latest)

west sky
#
plugins {
    id 'java'
}

group = 'com.alathreon'
version = '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.openjfx:javafx-graphics:17'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'

    testImplementation platform('org.junit:junit-bom:5.9.1')
    testImplementation 'org.junit.jupiter:junit-jupiter'
}

test {
    useJUnitPlatform()
}

I have this build.gradle
I can use ObjectMapper from jackson:databind
But I can't use any of the javafx stuff like Application, it just doesn't find them
Does anyone have any idea why ?

sour dewBOT
#

<@&987246554085740594> please have a look, thanks.

sour dewBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

swift quest
#

why not use the javafx plugin?

west sky
#

I prefer not to use it

swift quest
#

i dont see why not. its only a few extra lines```gradle
plugins {
id 'java'
id 'org.openjfx.javafxplugin' version '0.0.13'
}

group = 'com.alathreon'
version = '1.0-SNAPSHOT'

javafx {
version = '18.0.2'
modules = ['javafx.graphics']
}

repositories {
mavenCentral()
}

dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'

testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'

}

test {
useJUnitPlatform()
}```

west sky
#

I guess I will

#

but

#

do you have any idea why I can't use javafx components ?

swift quest
#

idk, ive never managed to get it to work without the plugin ¯_(ツ)_/¯

west sky
#

Because with maven, I just have to add the dependency

swift quest
#

don't you need javafx-base too?

west sky
devout smelt
#

I don't think specifying one module as a dependency would pull the entire SDK

devout smelt
#

Thats a module, not the SDK

west sky
devout smelt
#

Because the SDK is needed for JavaFX apps

#

Managing the SDK is one of the things the plugin does

west sky
#

it's what I always did

devout smelt
#

Not at a computer to reproduce that, but that doesn't sound right, unless Maven is pulling the SDK libraries with it. I'll have to see when I'm at a computer

#

Components are going to be under javafx.controls, so you could try adding that if your only problem is accessing components

west sky
#

wdym

devout smelt
#

But if you're having issues even importing Application, I would imagine it's because the libraries from the SDK are not being pulled

west sky
#

I mean

#

even if I use javafx.graphics

#

I can't find anything

#

no Application

#

no Scene

#

nothing

#

there is nothing in javafx.*

devout smelt
#

Are you using a modular project? Try adding requires statements in your module-info

west sky
#

i don't

digital garden
devout smelt
#

Then idk what to say, how are you running the project?

west sky
#

I mean

#

it doesn't even appear to compile in the intellij linter

#

it's red

devout smelt
#

Yeah, are you sure Gradle probably didn't pull the dependencies? Did you refresh Gradle?

#

It's usually part of the task that the Plugin configures for you

west sky
#

I did, I can find javafx in the dependency tree of gradle

tired compass
#

Can you share a screenshot of that?

devout smelt
#

So how the build tools manages modular frameworks is probably different

west sky
fast briar
#

javafx dependencies are tricky, there's some native stuff there too that you need to have

#

when you use the plugin, you can notice there's a whole bunch of deps

devout smelt
whole umbra
#

Because when I used javafx I had to mess around with the module thing

#

And with exports and stuff

#

And I didn’t do anything special for the project