I installed Eclipse IDE today on my Ubuntu Linux and then installed JavaFX using ‘Install New Software’ and when I created a javafx project, I got the following error in Main.java:
The import javafx cannot be resolved.
So, I listed the following directory to search for «jfxrt.jar»:
ls -l /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext
But I didn’t find «jfxrt.jar».
java -version
The output:
openjdk version «1.8.0_45-internal»
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
Uluk Biy
48.6k13 gold badges145 silver badges153 bronze badges
asked Sep 17, 2015 at 12:30
2
According to the packages list in Ubuntu Vivid there is a package named openjfx. This should be a candidate for what you’re looking for:
JavaFX/OpenJFX 8 — Rich client application platform for Java
You can install it via:
sudo apt-get install openjfx
It provides the following JAR files to the OpenJDK installation on Ubuntu systems:
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/ant-javafx.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/javafx-mx.jar
Hope this helps.
answered Dec 12, 2015 at 20:37
MWiesnerMWiesner
8,85811 gold badges36 silver badges70 bronze badges
4
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>
answered Jun 11, 2019 at 23:49
Ondra ŽižkaOndra Žižka
43.3k40 gold badges215 silver badges275 bronze badges
For Java Compiler 8 or above, do the following:
- Right-click on project
- Choose Build Path —-> Add Libraries
You will then be presented with the following screenshot below:
Make sure you have downloaded and installed a JDK 8 or above
When you press the finish button, all Java FX errors in your code should disappear.
Note Prerequisites:
JDK 9 installed and tested on NetBeans 8.0.1
answered Oct 22, 2017 at 15:48
MarkMark
5395 silver badges11 bronze badges
0
Solution 1
I’m going to run the HelloFX sample for Eclipse from the OpenJFX samples.
After I open the sample with VSCode, I see the reported error: [Java] The import javafx cannot be resolved [268435846]
.
This obviously means that JavaFX classes are not resolved, and even if there is an entry in the .classpath file:
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JavaFX11"/>
this library can’t be resolved.
Solving JavaFX SDK
So I’m going to replace that variable with the actual jars from my local JavaFX SDK:
<classpathentry kind="lib" path="/Users/<user>/Downloads/javafx-sdk-11.0.2/lib/javafx.base.jar"/>
<classpathentry kind="lib" path="/Users/<user>/Downloads/javafx-sdk-11.0.2/lib/javafx.graphics.jar"/>
<classpathentry kind="lib" path="/Users/<user>/Downloads/javafx-sdk-11.0.2/lib/javafx.controls.jar"/>
<classpathentry kind="lib" path="/Users/<user>/Downloads/javafx-sdk-11.0.2/lib/javafx.fxml.jar"/>
After refreshing the project, I can see under JAVA DEPENDENCIES
these jars.
While the error seems solved, the project still fails to build.
Solving JRE
We need to set JDK 11 for the project, so download it from here. Then open Eclipse and add it to the installed JREs. I see under Java -> Installed JREs -> Execution Environments
that the name for the 11 version is JavaSE-11
.
The .classpath
file from the helloFX project also contains a reference to the JRE:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/
org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
so I’m going to replace JDK11
with JavaSE-11
, and refresh the project. I can see under JAVA DEPENDENCIES
that there is a reference to JRE System Library [JavaSE-11]
.
Solving JAVA_HOME
We need to set the java.home
in VSCode.
This can be done in the settings.json
from `Preferences->Settings->Workspace Settings:
{
"java.dependency.packagePresentation": "hierarchical",
"java.home":"/Users/<user>/Downloads/jdk-11.0.2.jdk/Contents/Home"
}
After modifying it, you’ll get a popup with the message Java Language Server configuration changed, please restart VS Code.
, so restart it.
Trying it out
We can see that there are no errors, there is even a bin
folder with the result of the build that automatically VSCode does.
Can we run it? If we try it out, we’ll get an error:
Error: JavaFX runtime components are missing, and are required to run this application
This is the error you get when using JavaFX 11 without specifying the module-path.
Solving VM arguments
The final step consist on adding the required vm arguments.
This can be done in the launch.json
file. It contains a default configuration, that we can modify adding a new entry for the vmArgs
including the --module-path
with the local path to the JavaFX SDK and --add-modules
with the required JavaFX modules:
{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - Main",
"request": "launch",
"vmArgs": "--module-path /Users/<user>/Downloads/javafx-sdk-11.0.2/lib
--add-modules javafx.controls,javafx.fxml",
"mainClass": "hellofx.Main",
"projectName": "hellofx"
}
]
}
Now we have everything set.
Run the project again and it should work.
Note that I’m a first time user of VSCode, so I may have missed something obvious, and maybe some of these steps could be avoided or simplified.
Solution 2
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"request": "launch",
"vmArgs": "--module-path /Volumes/Data/kits/installations/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml,javafx.graphics",
"mainClass": "application.Main",
"name": "Launch Main",
"projectName": "GooDay"
}
]
}
add this to settings json
"java.dependency.packagePresentation": "hierarchical",
"java.home":"/Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home"
Related videos on Youtube
05 : 33
Visual Studio Code JavaFX Configure and Run
14 : 32
How to setup JavaFX Environment in Visual Studio Code?
10 : 47
Setting up VS Code for GUI development using JavaFX.
14 : 25
How to setup JavaFX in Visual Studio Code 2021
09 : 14
Configure VS Code for JavaFX Development #vscode #java #javafx #ui
03 : 03
Setting up environment for GUI development with JavaFX in VS Code Editor. [Modified and Efficient]
02 : 36
10 EASY STEPS to Use JavaFX in Visual Studio Code (VS Code) — 2021
Comments
-
I must be missing something obvious here… I am experimenting with VSCode (coming from Eclipse), but I am unable to get VSCode to see the JavaFX11 libraries. In the import statements, all references to JavaFX components are marked:
[Java] The import javafx cannot be resolved
In Eclipse, this is handled with a «User Library», which generates an entry in .classpath
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JavaFX11"> <attributes> <attribute name="module" value="true"/> </attributes> </classpathentry>
While VSCode seemingly understands the rest of the .classpath from Eclipse, it does not understand this. Replacing the path attribute with the actual location on disk also does not work.
For clarity:
- This question is specifically about Java 11. In earlier Java versions, JavaFX was part of the JDK. In Java 11, it has been moved to a set of external modules.
- I do not want to use Maven or Gradle. I need to directly reference the modules without using a build tool.
For extra points, it would be nice if VSCode could also directly execute the JavaFX application. However, it is acceptable if I have to start the application from the command line with explicit module- and class-paths
-
I download VSC and all the Java stuff you pointed to. It all worked out well. Had one simple problem with
"vmArgs": "--module-path /Users/<user>/Downloads/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml",
. I had to remove the newline and put it all on one line and it worked. My first attempt at Java 11. -
@Sedrick Yes, I know it is one line only, but I split it so reader could see the
--add-modules
part. -
Thanks for the tutorial!
-
@mipa The OpenJFX docs try to help people getting started with JavaFX 11 on their favorite IDE, and if there are more IDEs other than the three major Java IDEs, that could be done, of course if there is enough interest. Problem is to limit the extension of this… Could you file an issue here?
-
Wow — what a nice and amazingly thorough answer! Interestingly, did not need to set java.home. However, if you want to set this, the settings.json file may not be in the indicated location. To access it reliably, open the command palette (Ctrl-Shft-P), and then select the command «Open Settings (JSON)». This opens a nice editor where one can access user, workspace and folder settings.
-
@BradRichards I was using the Workspace Settings editor for that, but it is a json file nonetheless. About
java.home
, indeed it is not needed if you haveJAVA_HOME
already pointing to Java 11. -
the question is about fx11 specifically.
-
If your module path has spaces in it you need to provide escaped quotes for it.
Recents
Ranch Hand
Posts: 70
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Could it be problem with the JavaFX plug-in?
John Jai
Rancher
Posts: 1776
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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 Метки нет (Все метки)
Доброго всем времни суток.
Но при попытке запуска получаю следующее сообщение: Так же на строках импорта появляется сообщение: Попытался создать просто 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, спасибо. Добавлено через 1 час 18 минут 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 |
посмотрите часть про Access Rules. Сейчас перечитаю, но… 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 theEdit...
button, selectExternal location
, and find thesrc.zip
file under the lib folder of your local JavaFX SDK.
- Jar by jar, select
-
Jar by jar, select
Javadoc location
, press theEdit...
button, select Javadoc URL, and pastehttps://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
-
Вопрос заданболее трёх лет назад
-
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 руб./за проект
Минуточку внимания
Ranch Hand
Posts: 70
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Could it be problem with the JavaFX plug-in?
John Jai
Rancher
Posts: 1776
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
posted 11 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
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
According to the packages list in Ubuntu Vivid there is a package named openjfx. This should be a candidate for what youre looking for:
JavaFX/OpenJFX 8 – Rich client application platform for Java
You can install it via:
sudo apt-get install openjfx
It provides the following JAR files to the OpenJDK installation on Ubuntu systems:
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/ant-javafx.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/javafx-mx.jar
Hope this helps.
Heres 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>
java – The import javafx cannot be resolved
For Java Compiler 8 or above, do the following:
- Right-click on project
- Choose Build Path —-> Add Libraries
You will then be presented with the following screenshot below:
Make sure you have downloaded and installed a JDK 8 or above
When you press the finish button, all Java FX errors in your code should disappear.
Note Prerequisites:
JDK 9 installed and tested on NetBeans 8.0.1