Hot questions for Using Ubuntu in javafx

Question:

I tried to play simple mp3 file using javafx media player, and on windows everything works smoothly, how ever same code on Ubuntu 16.04 results in this error :

Exception in Application start method Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player! at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146) at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511) at javafx.scene.media.MediaPlayer.(MediaPlayer.java:414) at Test.start(Test.java:24) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139) ... 1 more Caused by: com.sun.media.jfxmedia.MediaException: Could not create player! at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:274) at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118) at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467) ... 11 more

And i dont think i am making any mistake, did anyone have similar problems under ubuntu because i have no idea what is causing this.

public class Test extends Application {

public static void main(String[] args) {
    launch(args);

}


@Override
public void start(Stage primaryStage) throws Exception {
    String musicFile = "/home/wrongway/Downloads/aaa.mp3";     // For example

    Media sound = new Media(new File(musicFile).toURI().toString());
    //  Media sound = new Media(musicFile.toString());
    System.out.println(musicFile.toString());
    MediaPlayer mediaPlayer = new MediaPlayer(sound);
    mediaPlayer.play();
}

}


Answer:

My bad guys, i was not aware until now that ubuntu 16.04 was not among supported operating systems for javafx 1.8.

My apologies!

Question:

Good day, I am trying to run a program called graphdb-native-app-8.8.1-jfx.jar on a ubuntu virtual machine. I have the latest version of java installed, and have made sure JAVA_HOME is set to the correct java-version.

java -version
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

I have also used sudo apt-get install openjfx to get JavaFX (and also for libopenjfx-java), and made sure it is the newest version by searching for updates:

sudo apt list --installed| grep jfx
libopenjfx-java/bionic,now 8u161-b12-1ubuntu2 all [installed] 
libopenjfx-jni/bionic,now 8u161-b12-1ubuntu2 amd64 [installed]
openjfx/bionic,now 8u161-b12-1ubuntu2 amd64 [installed]

Yet whenever I try to run the jar, I get the following error:

sudo /usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar ./graphdb-native-app-8.8.1-jfx.jar
Error: Could not find or load main class com.ontotext.graphdb.free.GraphDBFree
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

which leads to believe that the linux VM doesn't find javafx anyways or thinks it isn't installed.

I have scoured stackoverflow for similar questions, but most of them are solved by installing openjfx like I did. Others commence with their own .java files they want to compile and run with jfx and are solved by following the guides in https://openjfx.io/openjfx-docs/#install-javafx

Any help would be thoroughly appreciated, thanks in advance


Answer:

it seams that your java version is 11 and javafx for java 8 try to install the java 8 version and then maybe try again.

Question:

I have developed a Javafx application under IntelliJ IDEA. As a JavaFX project, I am given the option to build a native bundle alongside the .jar and .jnlp file. I choose to export a .deb native. I build and export the project on IntelliJ running on Ubuntu 14.04 64-bit. The .deb file is created. However, when I use Ubuntu Software Center to install the program, it prompts me with "The package is of bad quality"

This is the full error (save some repetitive lines):

Lintian check results for /home/guyfleeman/Dropbox/PROGRAMMING/Java/VaSOLSim/out/artifacts/VSS_TeacherClient/bundles/VSS-TeacherClient-1.0.deb:
E: VSS-TeacherClient: control-file-has-bad-permissions postinst 0775 != 0755
E: VSS-TeacherClient: control-file-has-bad-owner postinst guyfleeman/guyfleeman != root/root
E: VSS-TeacherClient: control-file-has-bad-permissions postrm 0775 != 0755
E: VSS-TeacherClient: control-file-has-bad-owner postrm guyfleeman/guyfleeman != root/root
E: VSS-TeacherClient: bad-package-name
E: VSS-TeacherClient: package-not-lowercase
E: VSS-TeacherClient: maintainer-address-missing Freeware - William Stuckey
E: VSS-TeacherClient: wrong-file-owner-uid-or-gid opt/ 1000/1000
E: VSS-TeacherClient: wrong-file-owner-uid-or-gid opt/VSS-TeacherClient/ 1000/1000
E: VSS-TeacherClient: wrong-file-owner-uid-or-gid opt/VSS-TeacherClient/VSS-TeacherClient 1000/1000
E: VSS-TeacherClient: wrong-file-owner-uid-or-gid opt/VSS-TeacherClient/VSS-TeacherClient.desktop 1000/1000
E: VSS-TeacherClient: wrong-file-owner-uid-or-gid opt/VSS-TeacherClient/VSS-TeacherClient.png 1000/1000
E: VSS-TeacherClient: wrong-file-owner-uid-or-gid opt/VSS-TeacherClient/app/ 1000/1000
E: VSS-TeacherClient: wrong-file-owner-uid-or-gid opt/VSS-TeacherClient/app/VSS-TeacherClient.jar 1000/1000
...

I have the choice to ignore these errors and install anyway. If I ignore the error, the program installs and runs fine.

Does anyone know how to properly export the .deb file under IntelliJ? Also, I figured this question would be more at home here rather than at superuser, but I'll move it upon request.

Thanks ahead of time.


Answer:

There was an issue in Java 7 when packaging Debian packages, which would lead to the "The package is of bad quality" warning.

(account needed to view the bug tracker info, but anybody can sign up for an account).

The issue was fixed for Java 8.

Question:

  • I built a small app using javafx ( very basic stuff )
  • compile using javac : OK ( oracle jdk 1.8.0_201-b09 )
  • crated the jar : OK : the jar works fine with java -jar
  • packaged the app using javapackager

    javapackager \ -deploy \ -daemon \ -srcfiles $JAR_FILE:./lib/$LIB_JAR.jar \ -outdir $DIST_FOLDER \ -outfile dist \ -native deb \ -appclass com.myapp.client.gui.Main \ -name "MyApp" \ -title "MyApp" \ -v

  • run the generated deb installer ( same machine )

  • go the the installed app under /opt/MyApp, and when I ran MyApp it just complains about GLIBCXX_3.4.21 not found

I have tried all sort of apt fixes but nothing worked..

it's worth mentioning that this is all done in a fresh ubuntu desktop version running from a virtual machine. ( ubuntu 14.04.1 amd64 )


Answer:

Try with jdk8u181 or less. The provided launcher from the jdk (in lib/ant-javafx.jar -> ./com/oracle/tools/packager/linux/JavaAppLauncher ) doesn't have the same symbol tables. It looks like a bug in oracle's jdk compilation and distribution system.

$ objdump -T 181/./com/oracle/tools/packager/linux/JavaAppLauncher

181/./com/oracle/tools/packager/linux/JavaAppLauncher:     format de fichier elf64-x86-64

DYNAMIC SYMBOL TABLE:
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSsaSEPKc
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dirname
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSsC1Ev
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 printf
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSspLEPKc
0000000000000000  w   D  *UND*    0000000000000000              __gmon_start__
0000000000000000  w   D  *UND*    0000000000000000              _Jv_RegisterClasses
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNKSs5c_strEv
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _Znam
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 __libc_start_main
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSsD1Ev
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dlclose
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSsC1EPKcRKSaIcE
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 readlink
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSaIcED1Ev
0000000000000000  w   D  *UND*    0000000000000000              __pthread_key_create
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZdaPv
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dlopen
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dlsym
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 setlocale
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSaIcEC1Ev
0000000000000000      DF *UND*    0000000000000000  GCC_3.0     _Unwind_Resume
0000000000400a50      DF *UND*    0000000000000000  CXXABI_1.3  __gxx_personality_v0


$ objdump -T 191/./com/oracle/tools/packager/linux/JavaAppLauncher

191/./com/oracle/tools/packager/linux/JavaAppLauncher:     format de fichier elf64-x86-64

DYNAMIC SYMBOL TABLE:
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dirname
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 printf
0000000000000000  w   D  *UND*    0000000000000000              __gmon_start__
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _Znam
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 __libc_start_main
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4.21 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4.21 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4.21 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dlclose
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 readlink
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSaIcED1Ev
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZdaPv
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dlopen
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 dlsym
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4.21 _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv
0000000000000000      DF *UND*    0000000000000000  GLIBC_2.2.5 setlocale
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4.21 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcRKS3_
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4 _ZNSaIcEC1Ev
0000000000000000      DF *UND*    0000000000000000  GCC_3.0     _Unwind_Resume
0000000000000000      DF *UND*    0000000000000000  GLIBCXX_3.4.21 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc
0000000000400be0      DF *UND*    0000000000000000  CXXABI_1.3  __gxx_personality_v0

Question:

Having trouble handling media keys in JavaFX (8.0.25) in Ubuntu 14.04. I can't tell any of them apart!

Example: mute button (XF86AudioMute / 121) event type: KEY_PRESSED code: UNDEFINED char: '' text: '' code.isMediaKey(): false

I get the same behavior with any of the other media keys, as well any unbound special application keys (dell keyboard with 'back arrow' 'forward arrow' 'home icon' etc)

xev can identify the keys just fine (ex: mute is 121)

How do I distinguish these key events in JavaFX?


Answer:

To answer my own question with a workaround:

I was not able to do this directly with JavaFX, instead I resorted to rebinding the media key to a function key: (example for mute button)

1. Unbind existing dconf setting: Note: this persists automatically dconf-editor or gsettings package: org.gnome.settings-daemon.plugins.media-keys key: volume-mute EX: gsettings set org.gnome.settings-daemon.plugins.media-keys volume-mute ''

2. Get keycode: xev | grep KeyPress -A 5 press desired key make note of keycode

3. Bind new mapping with xmodmap: Note: this does not persist automatically in 14.04, even when saved to ~/.Xmodmap xmodmap -pke > ~/.Xmodmap (to get current settings) Edit ~/.Xmodmap and make desired changes EX: keycode 121 = F11 F11 F11 F11 F11 F11 XF86Switch_VT_11 (mute button is now F11) Apply: xmodmap ~/xmodmap.conf

4. Persist option 1: add 'xmodmap ~/.Xmodmap' to a login script option 2: add 'usermodmap="$HOME/.Xmodmap" to /etc/gdm/Xsession