Search code examples
javaeclipsemedia-playercodenameone

MediaPlayer is complaining about a wrong JAVA version


I am getting the bellow error when I am trying to run the codename Media Player:

This fetaure is supported from Java version 1.7.0_06, update your Java to enable this feature

I have an eclipse Neon with the bellow java.home path

java.home=/usr/lib/jvm/java-8-openjdk-amd64/jre

Here is the output of my java -version

 java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

Given the abouve details I'd say that the error is inacurate?

Here is the code which I use to get some minimal http streaming.

Media video = MediaManager.createMedia("http://techslides.com/demos/sample-videos/small.mp4", true);


Form streaming = new Form(new BorderLayout());
Display.getInstance().scheduleBackgroundTask(() -> {
    video.prepare();
    Display.getInstance().callSerially(() -> {
        final MediaPlayer player = new MediaPlayer(video);
        player.setAutoplay(true);
        video.setNativePlayerMode(false);
        streaming.add(BorderLayout.CENTER, player);
        streaming.revalidate();
    });
});
streaming.show();

}


Solution

  • You are using OpenJDK instead of Oracle's Java. The problem is (as is almost always the case) with JavaFX which isn't bundled with OpenJDK and creates a mess of things.

    The solution is to install the Oracle JDK which will fix that message and get things like media/browser etc. working.