I have installed OpenJDK 8 and want to create a JavaFX app. Since JavaFX is not included in OpenJDK 8, I tried to install OpenJFX via maven:
downloaded org.openjfx:javafx-controls:11 and org.openjfx:javafx-fxml:11. It seems fine, the libs are resolved.
But when I execute the program, I get the following error message:
class file has wrong version 54.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
So I think I have the wrong version of the libs, since Java 8 is class file version 52. Is there a OpenJFX lib available for Java 8. Or did I miss something else?
Related
Is there any javafx/OpenJFX dependency which can be used directly in the pom file so that it works with OpenJDK 8? Or any workaround (without installing anything) which works with OpenJDK 8?
I have gone through a lot of similar questions on SO, but the solution to use JFX/OpenFX with OpenJDK 8 is either to install the openjfx package in Ubuntu OR use Oracle JDK 8. Unfortunately I cannot do both. I am using OpenJDK 8 and need to use javafx/OpenJFX within my swing application. The OpenJDK does not contain jfxrt.jar in its ext folder (as in case of Oracle JDK 8), and the versions of OpenJFX start from Java 9/10. And on trying to compile I get
class file has wrong version 54.0, should be 52.0 which is expected as it is build with Java 10
Any leads would be really helpful. Thanks!
I have already gone through the below links
Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?
"class file has wrong version 54.0, should be 52.0" while trying to build JavaFX application
"class file has wrong version 54.0, should be 52.0" while compiling javaFX project
How to find out JavaFX version
Is there any javafx/OpenJFX dependency which can be used directly in the pom file so that it works with OpenJDK 8?
AFAIK, no. There are org.openjfx artifacts for OpenJFX 11 onwards, but they won't work with Java 8. (The class file version will be wrong.)
Or any workaround (without installing anything) which works with OpenJDK 8?
I think you will need to build your own copy of OpenJFX from source, and (touch wood) "package it" with your application1.
(The following is purely based on reading the OpenJFX build instructions. I have not tried this out.)
So if you want to build a stand-alone OpenJFX 8 for use with OpenJDK 8, then you should try the following build instructions on the OpenJFX wiki:
Building OpenJFX 8u
The result of the build is (apparently) a ZIP file that is designed to be "overlayed" onto a JRE installation.
You may be able to repackage that into JARs and native libraries that you can include in your application.
For OpenJFX 9 and later, the build instructions are here:
Building OpenJFX
Apparently, for N >= 9, OpenJFX version N is supposed to be supported for OpenJDK N and OpenJDK N - 1. So if that is accurate, you should be able to build OpenJFX 9 for OpenJDK 8. On the other hand, the build instructions talk about generating modules, and module support is only available in Java 9 and later. However it is still worth a try (IMO).
1 - Options include 1) creating a custom Debian package(s) (or RPMs) ... analogous to the existing Ubuntu packages, 2) incorporating the relevant classes and native libraries into your application JAR, or 3) adding them to your applications classpath and library load path. You may need to experiment.
Why don't you just use, e.g., https://bell-sw.com/pages/downloads/#/java-8-lts and download the full Java version (not standard). It should already contain JavaFX and is one of the many OpenJDK 8 versions floating arround.
Two months ago I have developed a small application using JavaFX. It was before I have wiped Windows 10 out, and installed Ubuntu.
Today I had to do a small video showing the apps features, so I have created a project in IntelliJ from GIT, as a Maven project.
First of all, I had errors telling me that JavaFX cannot be found. So I have found out what happened with JavaFX - it is no longer inside the JDK but it is standalone now.
I have installed openjfx:
sudo apt-get install openjfx
It has downloaded version 11.0.2. I have added the jars to Global Libraries, and added them to my projects modules. The imports in Java files were now solved, but when I am trying to run the app - all I get is:
Error:(7, 26) java: cannot access javafx.application.Application
bad class file: /usr/share/openjfx/lib/javafx.graphics.jar!/javafx/application/Application.class
class file has wrong version 54.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
Should I get an earlier version of Openjfx? Or maybe there is another problem with my approach?
FYI: I have researched a ton of questions related to similar problems, but nothing worked. I even switched to Java 11, but this didn't work either.
Build Failure on Maven:
package javafx.application does not exist
I'm using JDK 8 because JDK 11 doesn't have JavaFX included by default.
I have openjfx listed in my pom file as a dependency.
I have JAVA_HOME set to:
$JAVA_HOME
bash: /usr/lib/jvm/java-8-openjdk-amd64: Is a directory
Is there an environment variable that needs to be set in order for Maven to find the JavaFX jars?
here is the terminal output and pom file
You are trying to use files compiled for version 54 (which is Java 10 according to https://en.wikipedia.org/wiki/Java_class_file#General_layout) and the Java 8 you are using does not understand any higher versions than 52.
You cannot use this javafx-base artifact with Java 8. Either revise your code or upgrade to at least Java 10.
Your Maven still use JDK 11.
Try Oracle JDK 8 for Linux https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html or you can install from software repos in Linux.
Try to remove, uninstall all things of JDK 11 (then check environment variables carefully, checking by command java -version and javac -version to be sure you are using JDK 8).
Clean (mvn clean) and re-build project.
Created a web app using maven and deployed it on heroku. Everything works find but when I call a action that uses the postgresql-9.2-1002.jdbc4 driver I get:
java.lang.UnsupportedClassVersionError: org/postgresql/Driver : Unsupported major.minor version 51.0 (unable to load class org.postgresql.Driver)
I know that the problem is I'm using jdk 7 on my development environment and a lower version is running on heroku (at least I think so). My first question is, why does the other actions don't give this error only actions that uses postqresql driver gives this problem the rest of the app works just fine? The other thing I did was download jdk 6 and then added it to my project build path, then configure eclipse compiler compliance to 1.6 but even then I have the same problem. How can I solve this?
For java 6 use:
postgresql-9.2-1004-jdbc4.jar
postgresql-9.3-1100-jdbc4.jar
For java 7 use:
postgresql-9.2-1004-jdbc41.jar
postgresql-9.3-1100-jdbc41.jar
The solution is to use a copy of the database driver that is compiled for JDK 6.
It seems that you are not getting the problem with your application code because your build changes worked. (Specifically the change to the compliance level. I don't think adding a JDK to the (regular) build path will make any difference.)
But of course, that won't make any difference for the database driver ... because you are not compiling that.
However, according to the download page, postgresql-9.2-1002.jdbc4 is supposed to be compatible with Java 6 as well as 7. So maybe you've gotten the JAR from somewhere else ... or by compiling from source with a Java 7 target.
UPDATE - I can confirm that the JAR on the download site has a Driver class whose bytecode version is 50.0 not 51.0. I suggest you download and use a fresh copy from there.
If you are using maven, the 9.2-1002-jdbc4 version on central repository has been compiled using 1.7 target. Use previous version until it has been fixed.
It seems that this has been resolved with the latest build ID 1003:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
Best way is to Install Higher Version of java that your Application Compile with and suppose if i have Application with compile with Jre 1.6 then i need 1.6 or Higher Version of Jre 1.6 and ya one thing is that
or
Just Compile your Class file i mean your application.java file with Default Jre that you have Available with java and Just Run on the same.
or Third Option.
Download that JRE and install that JRE version in your Machine.
I have encountered this problem and also the ClassNotFoundException for loading JDBC driver problem. The solution is to get the correct version of the postgres jar from http://jdbc.postgresql.org/download.html#jdbcselection. If you are using Maven, add the version of your dependency accordingly.
The alternative to swapping out your Java 6-incompatible Postgres driver for an alternative Java 7-friendly version (as recommended by most of the other answers) is to have Heroku use Java 7 to compile and run your application. If you're using JDK 7 for development, as you say, this might help avoid other incompatibilities.
To do this, follow these instructions on Heroku Devcenter. Here's a summary:
Create a file named system.properties in your app's base directory.
Add the property java.runtime.version=1.7 to the file, i.e.:
java.runtime.version=1.7
Commit the system.properties file and push to Heroku.
Had the same issue
On this page - http://jdbc.postgresql.org/download.html
Section - Current Version
Details about jvm versions and postgres jdbc drivers helped me figure it out.
In eclipse 3.4 I'm trying to do some performance tests on a large product, one of the included libraries is the vecmath.jar (javax.vecmath package) from the Java3D project. Everything was working fine and then when trying to run it yesterday I get this exception/error not long after starting it up:
java.lang.UnsupportedClassVersionError: javax/vecmath/Point2f (Unsupported major.minor version 49.0)
Which I believe means that I'm trying to load a java 1.5 class file into a 1.4 jvm which is unsupported. However when I went to the class file to check this I saw this in the eclipse class file viewer:
Compiled from Point2f.java (version 1.2 : 46.0, super bit)
So the class loader says it is version 49.0 but the class file says its 46.0. I've tried cleaning and fully rebuilding the project, I've confirmed that the compiler version for the project is 1.4, the JRE is 1.4 and for the run configuration the 1.4 jvm is selected. I'm totally stuck on this, does anyone have any idea what might be causing this?
Thanks
===EDIT===
It turns out that a version of java3d which was incompatible with java 1.4.2 had been installed in C:\Program Files\java\j2re1.4.2_18\lib\ext. I installed a newer version of Java3D to play around with in java6 and i guess it installed the libs in all my JREs even the ones which were incompatible.
Could there be another javax.vecmath.Point2f on your classpath?
I believe JRE 1.5 is required for the latest version of Java3D.
Have you checked:
Window
-> Preferences
-> Java
-> Compiler
-> Compiler Compliance Level
To see if this value is screwy?
You have to add the
"java_home : C:\Program Files\Java\jdk1.6.0_16"
"path: C:\Program Files\Java\jdk1.6.0_16\bin;"
to your Environment Variables!