0

My problem is the following: I cannot run .jar files built with java 1.8 after I installed Java 10.

In console, java -version shows:

java version "10.0.2" 2018-07-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

When I double click the .jar, it does not start, and when I run it from console with java -jar APP.jar, then I get following error: Missing JavaFX application class feedmeclient.FeedMeClient

Interesting thing is that IT WORKS if I revert to Java 1.8 or if I call java 1.8 with full path in console like this: "C:\Program Files (x86)\Java\jre8u162\bin\java.exe" -jar APP.jar, then it works with no problem.

APP.jar was built with NetBeans 8.2 Shouldn't Java be backward compatible?

The .jar file contains the MANIFEST and it looks like this:

Manifest-Version: 1.0
Implementation-Title: FeedMeClient
X-COMMENT: Main-Class will be added automatically by build
Implementation-Version: 1.0
Permissions: sandbox
Codebase: *
JavaFX-Version: 8.0
Class-Path: lib/CustomFXComponents.jar lib/FeedMeDataLayer.jar lib/com
 mons-io-2.4.jar
Created-By: JavaFX Packager
Implementation-Vendor: bostinac
Main-Class: feedmeclient.FeedMeClient
Florin Virtej
  • 435
  • 4
  • 7
  • I tried a simple example HelloWorld from https://docs.oracle.com/javafx/2/get_started/hello_world.htm, build it with Java 8, exported as Running jar (from eclipse) and it started with Java 10.0.2. I think that is not a Java-Problem. Have you checked that your main-class is really in the jar? – Ralf Renz Aug 01 '18 at 09:08
  • yes, I checked...the main class is in there. It runs with Java 8 when I call teh exact same APP.jar. Even stranger is that I also have other apps built with 1.8, and those work fine with both java 8 and java 10, is something only with this APP.jar and I cannot figure out what. I taught it may be something with libraries and class path, but they look similar (same libraries used, same class path) when I compare it with jar files that seem to not have this problem. – Florin Virtej Aug 01 '18 at 09:16
  • Can you start it directly from Netbeans with Java 10? – Ralf Renz Aug 01 '18 at 09:32
  • I was unable to add JDK 10 as a platform in NetBeans. It seems that the required javafx-src.zip (Platform sources) and Javadoc files are not inside JDK10 installation folder anymore, thus it cannot be used by NetBeans :(. – Florin Virtej Aug 01 '18 at 09:41
  • I just found this on NetBeans website. Does this mean there is a problem with the IDE and does not support Java > than 8? :( "JDK 8 is required for installing and running the Java SE, Java EE and All NetBeans Bundles. NetBeans 8.2 does not run on JDK9! You can download standalone JDK or download the latest JDK with NetBeans IDE Java SE bundle." – Florin Virtej Aug 01 '18 at 09:43
  • Maybe you switch to NetBeans 9. It is available at https://netbeans.apache.org/. – Ralf Renz Aug 01 '18 at 09:55
  • I will try it. Thanks a lot for your help. I'll come back when I have a solution. – Florin Virtej Aug 01 '18 at 10:11
  • Is there a `module-info.java` in the project? See also: https://stackoverflow.com/questions/48853477/java-cannot-find-javafx-classes-although-present-in-jdk – Itai Aug 01 '18 at 10:19

1 Answers1

0

So...after a lot of struggle I think I found the problem ... actually there were more problems:

  1. It seems that Netbeans 8.2 does not work with Java 9 or 10. I took NetBeans 9 from netbeans.apache.org as Ralf Renz suggested, and I was able to load the project into it, and compile it with JDK 10. Surprise surprise, when I ran it inside NetBeans I get the same Missing JavaFX application class feedmeclient.FeedMeClient error :)

    Also the IDE was struggling to scan the classes and to bring up the pop up where you select your main class of the project to be used. The dialog window will get stuck and no class was found....hmmm strange enough. The project did not had any error, it compiled and build just fine. Then I started to investigate libraries used. I use one library which I build also with Java 8, and this library called DataLayer.jar, was accessing files using JAXB to write and read XML files.

  2. Now the main problem: The JAXB used to be inside Java distribution untill now, but in Java 10 they removed it :((( Funny thing is that the IDE would not complain because the DataLayer.jar used as library was already compiled, and I guess it already contained needed classes. But somehow, something was still missing, because when I would ran DataLayer.jar individually, then it would crash because some JAXB symbols could not be resolved. At runtime that confusing "Missing JavaFX application class feedmeclient.FeedMeClient" was thrown even if it had nothing to do with the real reason of the problem.

Good thing is that you can get JAXB as library and use it in project. After I did this, everything went back to normal.

Community
  • 1
  • 1
Florin Virtej
  • 435
  • 4
  • 7