Error 3 26 java package javafx application does not exist

Environment IntelliJ version: IntelliJ IDEA Ultimate 2019.2 Issue I am unable to implement JavaFX into my duke project - I've added the JavaFX library to the Project Structure as well as in the...

@jolynnn8D

Environment

  • IntelliJ version: IntelliJ IDEA Ultimate 2019.2

Screenshot 2019-09-11 at 3 40 15 PM

Issue

I am unable to implement JavaFX into my duke project — I’ve added the JavaFX library to the Project Structure as well as in the Edit Configurations window for both Duke and Launcher classes:
Screenshot 2019-09-11 at 3 41 39 PM
Screenshot 2019-09-11 at 3 42 05 PM

However, when I run Launcher.main(), I get the following error even though the libraries seem to have been successfully imported within the code.
Screenshot 2019-09-11 at 3 43 24 PM

I have also attempted the Gradle method but it gives rise to another error which I suspect stems from the same issue:
Screenshot 2019-09-11 at 3 44 38 PM

Any help would be greatly appreciated!! T__T

@Nanosync

Have you tried re-importing the gradle project by hitting the refresh button in the Gradle tab of IntelliJ?

@jolynnn8D

Yep :( I still get the same error.

@danielwys

Can you push your branch-Level-10 in its current (broken) state to your repo so that it can be cloned?

@jolynnn8D

I’ve pushed it onto the repo!

@danielwys

Hmm, as @Nanosync suggested, you probably need to refresh your gradle configuration within IntelliJ. It might have been the case that you did not click the prompt to import gradle configuration changes within IntelliJ when you modified your build.gradle.

Try refreshing again? I’ve attached a gif of how to do so just in case:

2019-09-13 12-49-16 2019-09-13 12_50_47

Otherwise, can you also try re-importing your project?

  1. File > Close Project
  2. File > New > Project from Existing Sources
  3. Select the folder where duke is located
  4. Select Import Project from Existing Model and make sure Gradle is selected
  5. Let IntelliJ do its work
  6. Try launching the application again.

@damithc

@jolynnn8D

Fixed by deleting the wrapper folder, running gradle wrapper, then gradlew run

@damithc

Fixed by deleting the wrapper folder, running gradle wrapper, then gradlew run

Got it.

Thanks for the inputs @dawo5010


After automatically creating the JavaFX application project in Intellij IDEA, the Java compiler outputs the following message at startup:

`/home/greenmiler/IdeaProjects/untitled/src/main/java/sample/Main.java
Error:(1, 26) java: package javafx.application does not exist
Error:(2, 19) java: package javafx.fxml does not exist
Error:(3, 20) java: package javafx.scene does not exist
Error:(4, 20) java: package javafx.scene does not exist
Error:(5, 20) java: package javafx.stage does not exist
Error:(7, 27) java: cannot find symbol
  symbol: class Application
Error:(10, 23) java: cannot find symbol
  symbol:   class Stage
  location: class Main
Error:(9, 5) java: method does not override or implement a method from a supertype
Error:(11, 9) java: cannot find symbol
  symbol:   class Parent
  location: class Main
Error:(11, 39) java: cannot find symbol
  symbol:   method getClass()
  location: class Main
Error:(11, 23) java: cannot find symbol
  symbol:   variable FXMLLoader
  location: class Main
Error:(13, 35) java: cannot find symbol
  symbol:   class Scene
  location: class Main
Error:(19, 9) java: cannot find symbol
  symbol:   method launch(java.lang.String[])
  location: class Main`

As I understand it, Java may not import JavaFX, but why? The system has Oracle JDK 11 installed, which should include the JavaFX library, or am I wrong? I also tried to run the openjdk-11-jdk package on JDK c and the JavaFX command apt install openjfx-* installed, but the output did not change.
What am I doing wrong?

2 answers

Starting from versions after 8, JavaFX is allocated to a separate OpenJFX project, respectively, it is no longer supplied with the JDK. At one time, to run a project on JavaFX and OpenJDK 11, I drew information from hence

 4

Author: zolt, 2018-11-09 02:26:09

  1. You’re wrong. JavaFX is not included in Oracle JDK 11, it must be installed separately. If you want to have JavaFX included, install Oracle JDK 8.
  2. After installing the new JDK in the system, if you did not delete the previously installed previous version, you need to configure which of the previously installed JDKs will be used by the system by default. Run the command sudo update-alternatives --config java, select from the installed JDK/JVM the one you want to assign by default, check the settings java -version See here Choosing the default Java to use with pictures.
  1. На главную

  2. Java

  3. Ошибка: (3, 26) java: пакет javafx.application не существует
  • 2023
  • Редактор:
    Christopher Sullivan |
    Написать мне

У меня новый компьютер, я установил inteliJ с JDK и JRE 9.0.1. Я также установил SceneBuilder 9.0.1. Я скопировал проект, который был у меня на старом компьютере, и при его запуске получаю следующую ошибку: Ошибка: (3, 26) java: package javafx.application не существует. Нужно ли мне устанавливать что-то еще, что содержит этот пакет? Спасибо.

  • Какая ОС? Откуда вы устанавливали JRE?
  • вы используете модуль? если да, то вы наверняка не заявляете о зависимости от пакета.
  • Win 10, JRE от Oracle.
  • «вы используете модуль? если да, вы, вероятно, не заявляете о зависимости от пакета» — я не знаю, что здесь сказать
  • Отвечает ли это на ваш вопрос? IntelliJ не может распознать JavaFX 11 с OpenJDK 11

Пакет JavaFX не входит в JDK 9 и новее. Вам необходимо установить JDK 8, либо вы можете добавить пакет JavaFX отдельно, например, из JDK 8 ().

  • Это объясняет, почему учебник, который я смотрю, работает безупречно. Спасибо

Попробуйте это решение в IDEA, нажмите (Файл -> Структура проекта), затем выберите и выберите 8 или выше.

Если вы используете java 8+, библиотеки javafx не включены. вам нужно добавить их через ваш любимый инструмент сборки в качестве библиотеки времени выполнения компиляции.

  • Как это сделать? (В Windows)
  • какой инструмент сборки вы используете?
  • @Nikolay Hansen Eclipse

Быть осторожен. Это решение тестировалось только на Linux (Ubuntu 16.04 и Debian 8) и на Java 1.8. *

Это должно быть вашим идеальным решением. Попробуйте и наслаждайтесь. Если какая-то команда не работает должным образом, это означает, что вы получите какую-либо ошибку. Попробуйте сами решить. Я дал вам главное, что вам нужно. Если ваше приложение находится в другом месте, или ваша системная архитектура отличается. решайте сами. Сделать это очень просто. Просто следуйте моему данному решению.

Шаг 0:


Шаг 1


Шаг 2:


Шаг 3:


Шаг 4:


теперь откройте новый проект или перестройте свой проект. Удачи.

  • 4 Они сказали, что используют Windows — это все для Linux (в частности, Debian / Ubuntu), так что это не имеет значения.
  • 2 Это может не иметь отношения к OP, но имеет отношение к заголовку. Я пришел сюда за титулом, и этот ответ решил мою проблему.

Шаг 1. Настройка всего на java 9

Сначала вам нужно убедиться, что все настроено на java 9. Нажмите в Файл-> Структура проекта

  • На проект меню у вас есть Project SDK и уровень языка (Изображение)

  • И на модули в меню вам нужно проверить 2 вкладки (возможно, вам придется делать это для каждого модуля):

    • Souces имеет языковой уровень (Изображение)

    • И зависимости приобрел Модуль SDK (Изображение)

Шаг 2 Перестройка вашего проекта

Затем вам нужно перестроить свой проект:

Щелкните правой кнопкой мыши в вашем проекте и нажмите Восстановить модуль (Образ)

Затем просто подождите, пока ваш проект не будет перестроен, и попробуйте запустить его снова.

  • Я добавил кое-что, что вам может понадобиться сделать перед восстановлением проекта.

Hi everyone, my team and I have a maven project using jdk1.8 (not open jdk) and javaFX for our UI. It’s working well and there still a lot of work to do and we’d like to use the pipelines from Bitbucket to make continuous integration on the go.

I tried to use a simple .yml file :

image: maven:3.3.9-jdk-8
pipelines:
default:
- step:
caches:
- maven
script: # Modify the commands below to build your repository.
- mvn -B verify # -B batch mode makes Maven less verbose

But there is my problem, We are developping with IntelliJ and jdk1.8 where javaFX is standard and automatically included in the project. But the pipelines tries to use openjdk1.8, and can’t find the javaFX classes (especially the jfxrt.jar file).

If I do nothing and try as it is, the Maven error is :

[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[3,26] package javafx.application does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[4,19] package javafx.fxml does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[5,20] package javafx.scene does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[6,20] package javafx.scene does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[7,20] package javafx.stage does not exist

 I tried to include the jfxrt.jar file to maven to my pom.xml as a system dependency like that :

<dependency>
            <groupId>javafx</groupId>
            <artifactId>jfxrt</artifactId>
            <version>${java.version}</version>
            <scope>system</scope>
            <systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
</dependency>

But then Maven warns me he does not find the jfxrt.jar file :

[WARNING] 'dependencies.dependency.systemPath' for javafx:jfxrt:jar refers to a non-existing file /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar @ line 34, column 25

Mainly because he is using openjdk and not jdk.

I also tried to put the jfxrt.jar file inside the repository and make a dependency to it, it works but Maven warns me it’s not proper to do it like that :

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>2.0</version>
            <scope>system</scope>
            <systemPath>${basedir}/dependency/jfxrt.jar</systemPath>
        </dependency>

and the warning :

[WARNING] 'dependencies.dependency.systemPath' for com.oracle:javafx:jar should not point at files within the project directory, ${basedir}/dependency/jfxrt.jar will be unresolvable by dependent projects @ line 34, column 25[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

My question is how to either force Maven to use JDK and not OpenJDK (in Bitbucket !), or how to make a nice dependency to javaFX so Maven can verify our project everytime we push and not warn us.

Thank you all for your future responses.

Понравилась статья? Поделить с друзьями:
  • Error 293001 quartus prime full compilation was unsuccessful 3 errors 1 warning
  • Error 29142 vmware converter
  • Error 2908 could not register component corel
  • Error 2908 coreldraw как исправить
  • Error 285 роблокс