I am transiting my project to use openjdk 8 from adoptopenjdk... I understand that OpenJDK does not carry javafx anymore. So I set the org.openjfx.javafx as my dependencies for the project. I see the dependency connected... but why does my import still can not find it?
Building in local terminal is the same issue
error: package javafx.util does not exist
import javafx.util.Pair;
^
Dependences are all there...
compile 'org.openjfx:javafx-controls:11'
compile 'org.openjfx:javafx-fxml:11'
What am I missing?
What you are trying to achieve will never work because Java8 is simply not compatibel with JavaFX 11 or 12. You will either have to use a Java 8 distribution which contains JavaFX or you will have to upgrade your Java to at least 11 too.
Liberica JDK 8 is an OpenJDK distribution that contains JavaFX. Choose the Full JDK.
Related
I'm using Ubuntu 20.04 OS. I got
package javafx.application does not exist
error.I read all articles related to topic. I both set my default Java version 8 and also add the openjfx to the Intellij as module and library. Even if I tried solutions I found, still my problem doesn't solved. May it be related to something else that I didn't consider? Which other things I should also check?
Thanks a lot.
If you are working with Java 8, the easiest thing to do (and what I recommend), is to use Oracle JDK 8, not OpenJDK.
Most OpenJDK distributions do not include JavaFX, but Oracle JDK 8 does.
Downloading jfxrt.jar file from a github repo, and placing this file inside the necessary path, which is /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext solves the problem :)
(For Ubuntu 20.04, and Java 8)
I'm trying to compile a Java program using the Java 11 compiler from the command line on Arch Linux. The program compiles and works great from Eclipse IDE; however, when I try to compile it using the 'javac' command, it throws the following error:
javac MyApp.java
MyApp.java:3: error: package javafx.application does not exist
import javafx.application.Application;
^
MyApp.java:4: error: package javafx.stage does not exist
import javafx.stage.Stage;
Any help would be appreciated.
Regards
JavaFX is not part of the Java SDK anymore and needs to be installed separately (or you use Maven, Gradle or another build system). See the official documentation.
Build tools
Use a build tool such as Maven or Gradle to (a) download the desired version of the OpenJFX (JavaFX) libraries, and (b) include those libraries in your build, to be bundled inside your final JAR file.
JDK bundled with libraries
Or, use a JDK that includes the OpenJFX (JavaFX) libraries. Use such a JDK to compile. And ensure that your users have such a JDK installed on their computer.
This may work well in a controlled setting such as a corporate office, but may not be practical for distributing to the public.
At least two JDK vendors provide a variant of their distributions to include OpenJFX (JavaFX) libraries: Azul Systems, and BellSoft.
We have developed some framework using java 6 and maven. Now we are upgrading that but when we change the dependency for tools.jar from java 6 to java 8 we are getting compilation error at AnnotationProcessorFactory because in java 8 tools.jar com.sun.mirror package is missing which was in java 6 tools.jar.
Could you please suggest the way so that i can continue upgrade with java 8 .
What i tried :
I tried by adding apt-mirror-api-0.1.jar but that was not worked.
Please suggest.
Thanks,
Ganesh.
For such issue I found two approach ,
Build com.sun.mirror using jdk 6 tools.jar by adding dependency in maven and keep rest
for jdk 1.8 and during use in another project exclude com.sun.mirror in project
dependency.
We need to go for latest version of Enunciate.
https://github.com/stoicflame/enunciate/wiki/Migration-Guide
Welcome any suggestions.
Thanks,
Ganesh N.
I have searched but not found any detailed information about it. In http://www.oracle.com/technetwork/java/javafx/downloads/index.html it says
As of JDK 7u6 JavaFX is included with the standard JDK and JRE bundles
But I am getting error on compile the code includes javafx.* packages. The packages are not founding. I am using Oracle JDK 10.0.2 and Intellij Idea 2018.2. Code is worked after I added the $JAVA8_HOME/jre/lib/ext/jfxrt.jar as library.
But the strange thing is I am able to build the code to target bytecode version 8 without adding the jar file from JDK 8 as above.
So the question is
How can I get the latest JavaFX?
Is the latest JavaFX is in the JDK 8?
UPDATE
JDK 10 includes JavaFX and compiled and ran successfully in command line. There is a problem with Intellij IDEA 2018.2. It does not recognize the JavaFX packages.
The error message in Intellij:
Error:(3, 26) java: package javafx.application does not exist
Note: There is no error while coding in editor (Not underling red). Error occurs when compiling in Intellij.
Updated question title.
JavaFX is included in Oracle JDK up to and including Java 10. From Java 11 onwards it will not be included anymore but can be downloaded separately here http://jdk.java.net/openjfx/ .
Additional information on how to get started with JavaFX from version 11 onwards is also available here: http://docs.gluonhq.com/javafx11/ .
Problem solved with this step:
Set the Project byte code version to 10 instead of 8 in
File > Settings > Build, Execution, Deployment > Compiler > Java Compiler
Thanks for helps.
I am using jdk9-ea 149 and created a sample javafx application
IntelliJ doesn't understand the java libraries, It's shows all the import statement in red color and they are all grayed out.even for java.util.List, java.util.ArrayList it has the same issue.
I am able to compile form outside but i am not able to compile the code from IntelliJ 2016.3.2 Ultimate Edition.
It looks like we need to add some libraries to IntelliJ project but with java9 build 149 jigsaw i don't know how to do that.
I am using Experimental features still it doesn't understand the import statements - see intellij setting below
IntelliJ Version : IntelliJ 2016.3.2 Ultimate Edition
Java Version: java 9-ea build: 149
As mentioned in IntelliJ IDEA 2016.3.1 is Out:
Speaking of JDK 9, IntelliJ IDEA 2016.3 won’t support builds 148 and up because they contain code that breaks things. Of course, we’re working to resolve this, and will support the latest JDK 9 builds in 2017.1 (its EAP may well start within the next few weeks).
In IntelliJ IDEA 2017.1: Java 9, Kotlin 1.1, Spring, Gradle, JavaScript, Go and more it says:
The latest builds of JDK 9 are fully supported, with assisted project import and coding assistance for editing module declarations.
So if you are using Java 9 build 148 or higher, you need to use version 2017.1 or higher.
Alternatively, if you need to use an older version of IntelliJ, downgrade to Java 9 build 147 or lower.
The latest version of IntelliJ IDEA, 2017.1, does support jdk 9.