Codename One media file I/O exception on Arch Linux

Viewed 162

I am developing an Android application that I have almost finished on Ubuntu and that is gaining the final touch on Arch Linux.

I have reinstalled Java and Eclipse, and the project is running without a problem, except that the media files cannot be executed, even if the classes all the same and the media files in the same location.

The code is exactly the same, only the platform has changed. I have tried with both open-jdk-8 and open-jdk-11.

This is the code from a testing project:

    Form hi = new Form("Hi World", BoxLayout.y());
    Button buttonSound = new Button("Play");
    buttonSound.addActionListener(l -> {
        InputStream inputStream = Display.getInstance().getResourceAsStream(getClass(), "/children-hooray.wav");
        try {
            Media media = MediaManager.createMedia(inputStream, "audio/wav");
            media.play();
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    hi.add(buttonSound);
    hi.show();

enter image description here

Upon loading the console output is:

Adding CEF to classpath
Found theme.css file.  Watching for changes...
CSS> Retina Scale: 1.0
CSS> Using stateful mode. Use -help flag to see options for new stateless mode.
CSS> Looks like this CSS file needs CEF on classpath... adding it now, and retrying...
CSS> Adding CEF to classpath
Retina Scale: 1.0
CSS> Retina Scale: 1.0
CSS> Using stateful mode. Use -help flag to see options for new stateless mode.
CSS> Updating merge file /home/rainer/eclipse-workspace/A1_Test_En/css/theme.css.merged
CSS> Starting watch thread to watch [/home/rainer/eclipse-workspace/A1_Test_En/css/theme.css]
CSS> Compiling /home/rainer/eclipse-workspace/A1_Test_En/css/theme.css.merged to /home/rainer/eclipse-workspace/A1_Test_En/src/theme.res
CSS> File has not changed since last compile.
CSS> CSS file successfully compiled.  /home/rainer/eclipse-workspace/A1_Test_En/src/theme.res

and the Stack Trace is this :

    Adding CEF to classpath
    Retina Scale: 1.0
    java.io.IOException
    at com.codename1.impl.javase.JavaSEPort.createMedia(JavaSEPort.java:8506)
    at com.codename1.ui.Display.createMedia(Display.java:3597)
    at com.codename1.media.MediaManager.createMedia(MediaManager.java:308)
    at com.codename1.media.MediaManager.createMedia(MediaManager.java:226)
    at com.mycompany.myapp.Main.lambda$1(Main.java:65)
    at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349)
    at com.codename1.ui.Button.fireActionEvent(Button.java:687)
    at com.codename1.ui.Button.released(Button.java:728)
    at com.codename1.ui.Button.pointerReleased(Button.java:835)
    at com.codename1.ui.LeadUtil.pointerReleased(LeadUtil.java:153)
    at com.codename1.ui.Form.pointerReleased(Form.java:3817)
    at com.codename1.ui.Component.pointerReleased(Component.java:4710)
    at com.codename1.ui.Display.handleEvent(Display.java:2359)
    at com.codename1.ui.Display.edtLoopImpl(Display.java:1244)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:1162)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
1 Answers

With the aid from CN1, I finally managed to get ZuluFx installed and the media files working on Arch Linux. I post this in case my approach might be helpful to others:

  • Download ZuluFx form here (I have chosen to install Java version 11, but there are many more);
  • Extract it into this directory: /usr/lib/jvm/zulu11.45.27-ca-fx-jdk11.0.10-linux_x64;
  • Delete/ rename the directory /home/user/.codenameone/cef;
  • Change the Java version for the project following the guide here: Open Eclipse Window - Preferences -> Installed JRE -> Add -> Standard VM

This CN1-article is also a helpful read.

Related