Меню

The import javafx cannot be resolved ошибка

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Hi,

I am trying to develop any application using JavaFX. I am using Eclipse Indigo and JavaFX 2.0 SDK. I have installed the JavaFX plugin to eclipse and followed these steps to create a project: Create project using JavaFX.

But when I try this code:

I get the following multiple errors of this kind:

What do I do?


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

The error straight forwardly implies javafx is not present in the project’s class path. You should rather try the HelloWorld application provided in the tutorial link you posted.

And follow the steps from scratch to the HelloWorld program.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

John Jai wrote:The error straight forwardly implies javafx is not present in the project’s class path. You should rather try the HelloWorld application provided in the tutorial link you posted.

And follow the steps from scratch to the HelloWorld program.

I have added JavaFX to the project’s class path. I tried the HelloWorld program given there too. But the errors persist.

I am going through this thread. There seems to be no satisfactory conclusion there too.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Could it be problem with the JavaFX plug-in?

John Jai

Rancher

Posts: 1776


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Class path should point to a location where your class files (or jar files) are present. Is there a lib folder parallel to the bin in the Java FX installation? Does that have jar files?

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

John Jai wrote:Class path should point to a location where your class files (or jar files) are present. Is there a lib folder parallel to the bin in the Java FX installation? Does that have jar files?

There is no lib folder.


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

I moved this thread to JavaFX forum.

I dont think Eclipse has a plugin for JavaFX 2.0 yet, but this post would help you to configure your eclipse.

And the link you have mentioned is for older verion of JavaFX.

You can download Netbeans 7.1 beta from here which comes with JavaFX 2 support.

Note that JavaFX 2.0 is not compatible with older versions. So when you are searching use the version number.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:I moved this thread to JavaFX forum.

I dont think Eclipse has a plugin for JavaFX 2.0 yet, but this post would help you to configure your eclipse.

And the link you have mentioned is for older verion of JavaFX.

You can download Netbeans 7.1 beta from here which comes with JavaFX 2 support.

Note that JavaFX 2.0 is not compatible with older versions. So when you are searching use the version number.

Since my entire project is in Eclipse, I would like to stick on to Eclipse. Which (older)version of JavaFX do I have to install? Could you please give me the link?

Mohamed Sanaulla

Bartender

Posts: 3225

IntelliJ IDE
Oracle
Spring
Chrome
Java


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Did you visit the link I provided in my reply for configuring Eclipse?

You should be using JavaFX 2.0 and above version. Older versions are not supported anymore.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:Did you visit the link I provided in my reply for configuring Eclipse?

You should be using JavaFX 2.0 and above version. Older versions are not supported anymore.

Thank you. I don’t get this error now-

But there is this error in the line 11 of the code I posted in the first post of this thread-

What do I do?

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Shikha Upadhyaya wrote:

But there is this error in the line 11 of the code I posted in the first post of this thread-

What do I do?

I fixed this error.

But now I have a new exception in my program.

How do I set this right?

Mohamed Sanaulla

Bartender

Posts: 3225

IntelliJ IDE
Oracle
Spring
Chrome
Java


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Have you installed the JavaFX SDK? I think its missing the runtime related files. Not sure though. Try installing runtime again.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:Have you installed the JavaFX SDK?

I have installed JavaFX 2.0 SDK which is now located in C:/Program Files/Oracle. I have also set the class path to C:/Program Files/Oracle/JavaFX2.0 SDK.

Mohamed Sanaulla wrote:I think its missing the runtime related files. Not sure though. Try installing runtime again.

I have installed and uninstalled and again installed JavaFX 2.0 SDK twice. No change in the exception list. Is there something called installing the runtime separately? If yes, how do I do it?

But I would like to stress upon one observation here. When I click on File > New > JavaFX project, a window «New JavaFX project» opens. In that window I can see an error message- A valid JavaFX SDK was not detected.

Mohamed Sanaulla

Bartender

Posts: 3225

IntelliJ IDE
Oracle
Spring
Chrome
Java


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

If you have JavaFX SDK then you have the runtime as well.

Shikha Upadhyaya wrote:

But I would like to stress upon one observation here. When I click on File > New > JavaFX project, a window «New JavaFX project» opens. In that window I can see an error message- A valid JavaFX SDK was not detected.

I dont think Eclipse supports New JavaFX project as I am not sure if Eclipse has a plugin to support JavaFX 2.0. You must be creating a usual Java project and then follow the JavaFX sample code — Am just thinking loud here, not tried it.

But on Netbeans 7.1 beta you can create a new JavaFX project and proceed with the development — I have tried this though.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:If you have JavaFX SDK then you have the runtime as well.

I dont think Eclipse supports New JavaFX project as I am not sure if Eclipse has a plugin to support JavaFX 2.0. You must be creating a usual Java project and then follow the JavaFX sample code — Am just thinking loud here, not tried it.

But on Netbeans 7.1 beta you can create a new JavaFX project and proceed with the development — I have tried this though.

Oh Shifting the entire project to Netbeans would be tedious. There’s nothing at all which can be done. Any other breakthrough using Eclipse only as the IDE?

Mohamed Sanaulla

Bartender

Posts: 3225

IntelliJ IDE
Oracle
Spring
Chrome
Java


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

You can try creating a usual Java project and then add the javafxrt jar as mentioned here and then try to create the sample application. Also uninstall the javaFX plugin which you have installed for Eclipse.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:You can try creating a usual Java project and then add the javafxrt jar as mentioned here and then try to create the sample application. Also uninstall the javaFX plugin which you have installed for Eclipse.

I just tried this piece of code. The same set of exceptions continue to show up.

Mohamed Sanaulla

Bartender

Posts: 3225

IntelliJ IDE
Oracle
Spring
Chrome
Java


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

I used Eclipse Helios to run JavaFX application and it works. I didnt install any JavaFX plugin for Eclipse.

Also I created a simple Java project and then added the following:

I also added the jfxrt.jar to the External jars for the project.

I was able to run the application.

Also please use the tutorials from this page as they are relevant for the latest release of JavaFX

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:I used Eclipse Helios to run JavaFX application and it works. I didnt install any JavaFX plugin for Eclipse.

Also I created a simple Java project and then added the following:

I also added the jfxrt.jar to the External jars for the project.

I was able to run the application.

Also please use the tutorials from this page as they are relevant for the latest release of JavaFX

Oh then *Eclipse Indigo* is the problem!!

Mohamed Sanaulla

Bartender

Posts: 3225

IntelliJ IDE
Oracle
Spring
Chrome
Java


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Oh then *Eclipse Indigo* is the problem!!

I dont think it should be the problem.

What is the version of JRE you are using when you are trying to run the application? What matters here would be the JavaFX library and the runtime and the compatible JRE version.

Shikha Upadhyaya

Ranch Hand

Posts: 70

Chrome


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:I dont think it should be the problem.

What is the version of JRE you are using when you are trying to run the application? What matters here would be the JavaFX library and the runtime and the compatible JRE version.

When I created the project I had checked JavaSE 1.6 as the execution environment JRE in the New Java Project window.

Mohamed Sanaulla

Bartender

Posts: 3225

IntelliJ IDE
Oracle
Spring
Chrome
Java


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Shikha Upadhyaya wrote:

Mohamed Sanaulla wrote:I dont think it should be the problem.

What is the version of JRE you are using when you are trying to run the application? What matters here would be the JavaFX library and the runtime and the compatible JRE version.

When I created the project I had checked JavaSE 1.6 as the execution environment JRE in the New Java Project window.

I think JavaFX 2 required Java SE 7, so you would have to change in the preferences to use Java 7

Pb-BASS

7 / 7 / 2

Регистрация: 21.02.2019

Сообщений: 134

1

24.04.2019, 08:35. Показов 8258. Ответов 5

Метки нет (Все метки)


Доброго всем времни суток.
Помогите решить вот такую проблемку.
Установил среду Eclipse. В ней установил через Marketplace e(fx)eclipse.
Скачал javafx-sdk-11.0.2. Распаковал архив.
Пытаюсь создать JavaFX приложение. Среда создает стандартную заготовку:

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package application;
    
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
 
public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            BorderPane root = new BorderPane();
            Scene scene = new Scene(root,400,400);
            scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    
    public static void main(String[] args) {
        Application.launch(args);
    }
}

Но при попытке запуска получаю следующее сообщение:
Error: Unable to initialize main class application.Main
Caused by: java.lang.NoClassDefFoundError: Stage

Так же на строках импорта появляется сообщение:
The import javafx cannot be resolved

Попытался создать просто Java проект и импортировать в него необходимые библиотеки. Но и эта попытка завершилась неудачей.

Кто знает, в чем может быть причина?

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



1227 / 844 / 260

Регистрация: 02.04.2009

Сообщений: 3,175

24.04.2019, 10:37

2



1



7 / 7 / 2

Регистрация: 21.02.2019

Сообщений: 134

24.04.2019, 12:53

 [ТС]

3

Kukstyler, спасибо.
Но столкнулся с такой проблемой.
В статье сказано, что требуется файл jfxrt.jar
Он у меня есть и лежит в папке jre1.8.0_211
Но, если я правильно понимаю, среда программирования использует JDK. А он лежит в папке jdk-12.0.1
Получается какая-то несовместимость,которую я никак не разберусь.

Добавлено через 1 час 18 минут
Через Windows — Preferences — Java — Installed JREs добавил jre1.8.0_211, но это проблему не решило. В чем может быть проблема, кто может подсказать?



0



1227 / 844 / 260

Регистрация: 02.04.2009

Сообщений: 3,175

24.04.2019, 13:02

4

Pb-BASS, посмотрите часть про Access Rules.



1



7 / 7 / 2

Регистрация: 21.02.2019

Сообщений: 134

24.04.2019, 13:10

 [ТС]

5

Цитата
Сообщение от Kukstyler
Посмотреть сообщение

посмотрите часть про Access Rules.

Сейчас перечитаю, но…
Я только что замен в разделе JRE System Library SDK12 на jre1.8 и проект стал работать. Но остался один вопрос.
Получается, что для компиляции и запуска проекта я сейчас использую утилиты из комплекта JRE. Но размве в состав JRE входит компилятор? Это е вроде только Java машина для запуска уже написанных программ. А для разработки требуется использовать JDK? Или я что-то путаю.



0



Create an account to follow your favorite communities and start taking part in conversations.

r/javahelp

Posted by4 years ago

Archived

The import javafx cannot be resolved

AAAAAAAAAAAA wat do?

This thread is archived

New comments cannot be posted and votes cannot be cast

level 2

It wound up saying that I have to install jdk 12, which is apparently only done by extracting an archive to somewhere. And I can’t figure out where that directory is supposed to be in ubuntu.

level 1

I believe after JDK 8, but maybe its jdk 10, oracle made fx a separate package. I ran into this problem using Java 11. Search for the javafx download, it’s a separate download than the normal jdk. you’ll then have to add it as a global or project library in eclipse.

level 2

For me, it was the excuse to start learning Maven. It was a good kick in the pants for that.

level 1

I recommend u changing to netbeans, ive been using eclipse for lst year and i think now that il using netbeans everything is easier.

level 2

netbeansIntelliJ fixed that for you.

About Community

General subreddit for helping with **Java** code.



Here’s how to set it up on Ubuntu Linux with Maven:

1) Install OpenJFX package, check where did it put the files.

      sudo apt install openjfx
      dpkg-query -L openjfx

You might end up with version for JDK 11. In which case, either follow with installing a new OpenJDK, or set a version of OpenJFX for JDK 8.

2) Put it to your Maven project as a system-scoped dependency.

Note this is the lazy and not-so-nice way. Properly, you should install the jars like this:

dpkg-query -L openjfx | grep -E '.jar$' | xargs -l -I{} 
  mvn install:install-file -Dfile="{}" -DgroupId=javafx 
    -DartifactId=$(echo $JAR | tr '.' '-') -Dversion=1.0 -Dpackaging=jar

And then use it as a normal compile-scoped dependency.

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.source.level>1.8</project.source.level>
    <project.target.level>1.8</project.target.level>

    <javafx.dir>/usr/share/openjfx/lib</javafx.dir>
</properties>

<dependencies>

    <!-- JavaFx :
      sudo apt install openjfx
      dpkg-query -L openjfx
    -->
    <dependency>
        <groupId>javafx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${javafx.dir}/javafx.base.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>javafx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${javafx.dir}/javafx.controls.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>javafx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${javafx.dir}/javafx.fxml.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>javafx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${javafx.dir}/javafx.graphics.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>javafx</groupId>
        <artifactId>javafx-media</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${javafx.dir}/javafx.media.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>javafx</groupId>
        <artifactId>javafx-swing</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${javafx.dir}/javafx.swing.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>javafx</groupId>
        <artifactId>javafx-web</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${javafx.dir}/javafx.web.jar</systemPath>
    </dependency>

</dependencies>

Я пытаюсь экспортировать подключаемый модуль Eclipse. Это только одно представление Eclipse, которое я создал из примера здесь: http://help.eclipse.org/mars/index.jsp?nav=%2F2_0

Пока плагин работает нормально, я получаю следующую ошибку при экспорте (в качестве развертываемых плагинов и фрагментов):

# 12/15/15 8:58:14 AM CET
# Eclipse Compiler for Java(TM) v20150902-1521, 3.11.1, Copyright IBM Corp         2000, 2015. All rights reserved.
----------
1. ERROR in C:temp[...].java (at line 22)
    import javafx.embed.swt.FXCanvas;
           ^^^^^^^^^^^^^^^^
The import javafx.embed.swt cannot be resolved

Я попытался разрешить это, добавив javafx.embed.swt к импортированным пакетам в MANIFEST.MF, но это не помогло. Также я проверил зависящие от плагина проекты, и там отображается jfxswt.jar.

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

!ENTRY org.eclipse.equinox.event 4 0 2015-12-15 12:25:48.193
!MESSAGE Exception while dispatching event org.osgi.service.event.Event    [topic=org/eclipse/e4/ui/model/ui/UIElement/toBeRendered/SET]     {ChangedEle[email protected]1ac3a    6f (elementId: com.[...].View, tags: [View,      categoryTag:[...]Tools Category], contributorURI: null) (widget:      ContributedPartRenderer$2 {}, renderer:       or[email protected]1dc9aba0,     toBeRendered: true, onTop: false, visible: true, containerData: null,     accessibilityPhrase: null) (contributionURI:    bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.   CompatibilityView, object: null, context: PartImpl     (com.[...].View) Context, variables: [], label: [...]Graph, iconURI: platform:/plugin/com.[...]/icons/sample.gif, tooltip: , dirty: false, closeable: true, description: null), Widget=null, AttName=toBeRendered, NewValue=true, EventType=SET, OldValue=false} to handler org.eclipse.e4[email protected]12e9e909
!STACK 0
java.lang.Error: Unresolved compilation problems: 
The import javafx.embed.swt cannot be resolved
FXCanvas cannot be resolved to a type
FXCanvas cannot be resolved to a type
FXCanvas cannot be resolved to a type
FXCanvas cannot be resolved to a type

at com.[...].View.<init>([...]View.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at org.eclipse.ui.internal.registry.ViewDescriptor.createView(ViewDescriptor.java:58)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:101)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPart(CompatibilityPart.java:279)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:317)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:898)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:879)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:121)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:345)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:264)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:104)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:73)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:55)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:971)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:640)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:746)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:717)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:711)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:695)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.subscribeTopicToBeRendered(PartRenderingEngine.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.di.internal.extensions.EventObjectSupplier$DIEventHandler.handleEvent(EventObjectSupplier.java:83)
at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:85)
at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:59)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setToBeRendered(UIElementImpl.java:303)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:489)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:458)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:724)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:701)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:639)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:634)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1157)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1140)
at org.eclipse.ui.handlers.ShowViewHandler.openOther(ShowViewHandler.java:102)
at org.eclipse.ui.handlers.ShowViewHandler.execute(ShowViewHandler.java:75)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:343)
at org.eclipse.ui.internal.ShowViewMenu$3.run(ShowViewMenu.java:147)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)

How do I import the javafx correctly into eclipse? («The import cannot be resolved»)

nninja :

I looked on many similar questions but the solutions didnt help me 🙁

This is my openjfx lib

This is the jfx doc

I can import the lib in 2 ways:

1. In the java build path I can use this way all the classes without problems… BUT i cant load the java doc or source, if i do, it does not work.

or…

2. edit the installed JRE definitions This way I add like explained in other Questions the jfxrt.jar in the installed jre and i give it the source and doc. AND it WORKS! … nearly… The documentation works now… but not all imports. 🙁

import javafx.application.Platform;       //this works
import javafx.scene.control.ListView;     //this works
import javafx.scene.control.ProgressBar;  //this works
import javafx.scene.control.TextField;    //this works
import javafx.scene.layout.Background;    //this DOES NOT work :(
import javafx.scene.layout.BackgroundFill;//this DOES NOT work :(
import javafx.scene.layout.Border;        //this DOES NOT work :(
import javafx.scene.layout.BorderPane;    //this works again ._.

The error i get is: «The import javafx.scene.layout.Background cannot be resolved»

Well… when doing the 1st step (from This is my openjfx lib). I have absolutly no import issues and i can work perfectly, but the doc doesnt work.

And now with 2. edit the installed JRE definitions the doc does work but i have import issues with certain stuff and i dont understand why 🙁

Obviously I am doing something wrong… (i am pretty new to java)

my java -version:

java version "13" 2019-09-17
Java(TM) SE Runtime Environment (build 13+33)
Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)

(i had some bug earlier using the fx and it got fixed by updating my eclipse 2019-09)

Well. i hope you can help me ^^

José Pereda :

To run JavaFX 11+ on Eclipse, you have to follow the documentation here: https://openjfx.io/openjfx-docs/#IDE-Eclipse.

If you are not using Maven/Gradle build tools:

  • Download the JavaFX 13 SDK from here
  • Create a JavaFX13 library with the JavaFX jars.
  • Add the VM arguments to your run configuration.

JavaDoc and Sources

To get javadoc and sources working, you shouldn’t add a (very old) jfxrt.jar, that is from and old JavaFX version, so you will get mismatches because some changes in packages.

The proper way to do it, if you already have your JavaFX13 library is:

  • Edit the library (Eclipse -> Preferences -> Java -> Build Path -> User Libraries -> JavaFX13), and display all the jars included. If you display the content of any of these jars, you will probably see:

    Source attachment: (None)
    Javadoc location: (None)
    
    • Jar by jar, select Source attachment, press the Edit... button, select External location, and find the src.zip file under the lib folder of your local JavaFX SDK.

Source and Javadoc

  • Jar by jar, select Javadoc location, press the Edit... button, select Javadoc URL, and paste https://openjfx.io/javadoc/13/.

  • Apply and close, when done.

You should now get Javadoc when hovering any JavaFX class, and also access to source code when Ctrl+Click a JavaFX class.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at2020-09-11

Related

Я только учусь и сразу же возникли проблемы с JavaFX. Библиотеки я подключил! Всё установил, а всё ровно ошибка!
Main:

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        //Parent root = FXMLLoader.load(getClass().getResource("/fxml/main.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }

Conroller:

package sample;

public class Controller {
}

sample.fxml:

<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="sample.Controller"
          xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>

Сама ошибка!!!

"C:Program FilesJavajdk-12binjava.exe" "--module-path=C:Program FilesJavajavafx-sdk-11.0.2lib--add-modules=javafx.controls" --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.1libidea_rt.jar=63514:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.1bin" -Dfile.encoding=UTF-8 -classpath "C:UsersdpozhDesktopJAVAJAVA-KODlesson16outproductionlesson16;C:Program FilesJavajavafx-sdk-11.0.2libsrc.zip;C:Program FilesJavajavafx-sdk-11.0.2libjavafx-swt.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.web.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.base.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.fxml.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.media.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.swing.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.controls.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.graphics.jar" -p "C:Program FilesJavajavafx-sdk-11.0.2libjavafx.base.jar;C:Program FilesJavajavafx-sdk-11.0.2libjavafx.graphics.jar" sample.Main
Exception in Application start method
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
	at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x7f1029bf) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x7f1029bf
	at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38)
	at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056)
	at sample.Main.start(Main.java:13)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
	... 1 more
Exception running application sample.Main

Process finished with exit code 1

5c9faf10850ca768187851.png5c9faf18b0bf7695742910.png


  • Вопрос задан

    более трёх лет назад

  • 10643 просмотра

Всё заработало, установил jdk 8u201

Пригласить эксперта

У вас ошибка class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x7f1029bf) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x7f1029bf сообщает о том, что он не может что-то найти/подключить.

Так как в VM options у вас был указан —add-modules javafx.controls, но нет, например, javafx.fxml и javafx.graphics, предлагаю именно их и добавить (через запятую после —add-modules javafx.controls).

Я сам потратил некоторое время, но разобрался. Для себя в поле VM options прописал следующее:

--module-path "C:Program FilesJavajavafx-sdk-11.0.2lib" --add-modules javafx.controls,javafx.fxml,javafx.base,javafx.graphics,javafx.web --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED

У меня заработало))


  • Показать ещё
    Загружается…

29 янв. 2023, в 03:07

300000 руб./за проект

29 янв. 2023, в 02:16

700000 руб./за проект

29 янв. 2023, в 01:54

5000 руб./за проект

Минуточку внимания

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • The image could not be loaded magnific popup ошибка
  • The hunter call of the wild ошибка при запуске приложения 0xc0000142