Forum Stats

  • 3,826,741 Users
  • 2,260,701 Discussions


Java Puzzle Ball with JRE 9

NickR2600-Oracle Member Posts: 530 Employee
edited May 31, 2017 5:21PM in Java Puzzle Ball

I've made a few changes so that Java Puzzle Ball now works with JRE 9.  The latest version of the game (Version 3.1) is available on the MOOC and seems to be working on JRE 9.  The problem was that a number of JavaFX *Builder classes seem to be removed from the Java API between Java 8 and Java 9.  In other words, commands which worked fine with Java 8 are no longer available with Java 9.  This was easy spot in NetBeans.  But if you don't have the source code and want to diagnose other Java applications which don't work in Java 9, Java 9 provides an interesting tool called jdeprscan to search for deprecated APIs  One quick scan, and I got the following results:


The solution was to change the Transitions to edit their fields one-by-one instead of using a Builder.  For example:

FadeTransition fadeTransition = FadeTransitionBuilder.create()    .duration(Duration.seconds(0.4))    .node(imageView)    .fromValue(1)    .toValue(0)    .build();fadeTransition.playFromStart();


FadeTransition fadeTransition = new FadeTransition();fadeTransition.setDuration(Duration.seconds(0.4));fadeTransition.setNode(imageView);fadeTransition.setFromValue(1);fadeTransition.setToValue(0);fadeTransition.playFromStart();

FadeTransitions are used to fade out game objects, like the ball when it's repositioned back to its starting point, or bumpers when they're destroyed.  Java Puzzle Ball is still a Java 8 application.  I'd need to experiment with Java 9 modules (Jigsaw) if I were to release the game as a Java 9 application.  In the meantime, these changes should add future-compatibility with JRE 9.  Java 9 won't officially release for another few months.  But it is possible to get your hands on an Early Access version of Java 9, deprescan, and NetBeans 9.