#Can't import javafx.scene.control.Alert

36 messages · Page 1 of 1 (latest)

unborn swift
#

Hello im a newbie so bare with me please.
So im watching a tutorial and they use an Alert but then i need to import first right? before i can use the Alert.
im using JDK 1.8.0

so im looking through the internet and it says that the alert should be includeed in the package jdk 1.8.0 but in my case i cant import it . the only thing it says when i try to import it is as show in the picture.

Any idea how will i resolve this?

gray boughBOT
#

This post has been reserved for your question.

Hey @unborn swift! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

lilac shard
#

well, do you have javafx added as a library?

unborn swift
#

i think no

#

where do i find it

lilac shard
#

are you using maven or gradle?

#

maven:

<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx</artifactId>
    <version>11</version>
    <type>pom</type>
</dependency>
#

gradle:
implementation group: 'org.openjfx', name: 'javafx', version: '11', ext: 'pom'

#

assuming javaFX isnt packaged with your java installation

unborn swift
#

it doesnt say anything about jdk1.8 , what should i do

open pawn
#

Are you sure you are using jdk 8?
open command line and type in java -version and check the output

open pawn
#

did you try importing everything from control?
import javafx.scene.control.*;

#

You could also remove the import statement, then declare the Alert in your code and try to use the IDE to import it for you

unborn swift
#

yes but it just gives me the same result

sly jungle
#

Hi, what version of Java have you set in your IDE?

#

Maybe it's just an IDE what has an issue, not code itself

unborn swift
#

how do i check it. is this it?

sly jungle
#

It is version of Java used to run NetBeans

open pawn
sly jungle
#

It is not related to what is used as compiler

open pawn
#

ahh yeah, might be the bundled one

sly jungle
#

Right click on your project --> Project Properties

What version do you see?

#

Or send us a screenshot

unborn swift
sly jungle
#

Hmmm 🤔 seems to be correct

#

Can you import any other class from JavaFX, or only have issues with Alert?

unborn swift
sly jungle
#

Hah, than you might have old version of Java 8 🤣

open pawn
#

I suggest installing one of the new JDK versions from the link above and set that JDK to be used in your project
do not use the bundled netbeans java

unborn swift
#

i forgot to message here. thank you guys from 1.8.0 i tried 8u361 and it works🎉

gray boughBOT