Home > Back-end >  How can I run a .jar file that was build for Windows and Mac in Linux?
How can I run a .jar file that was build for Windows and Mac in Linux?

Time:11-30

I need to run a Java app ("Exactly") on Linux. It is a software to transfer data and used by an institution I have to cooperate with. https://www.weareavp.com/products/exactly/ Codebase is here: https://github.com/WeAreAVP/uk-exactly

Unfortunately, the programs website offers only downloads for Mac and Windows, but essentially it is a Java Application. Until now, I though, Java Applications run on every platform that supports a virtual Java machine. For older versions of "Exactly" there were also a dedicated .jar download available. In the current "Exactly" User Guide (https://www.weareavp.com/wp-content/uploads/2018/06/Exactly-User-Guide_v.0.1.5.pdf) I found this sentence: "The​ ​Java​ ​jar​ ​file​ ​is​ ​now​ ​contained​ ​within​ ​either​ ​of​ ​the​ ​two​ ​Windows​ ​packages​ ​(32​ ​or​ ​64).​ ​You​ ​can​ ​run the​ ​Java​ ​jar​ ​file​ ​(located​ ​in​ ​the​ ​/dist​ ​path)​ ​once​ ​you​ ​unzip​ ​the​ ​Windows​ ​package."

I downloaded and unziped the Java files from the 64bit package to the directory: ~/java-anwendungen/exactly/

In ~/java-anwendungen/exactly/dist I found the exactly.jar file. I made it executable and tried to start it with no success.

$ java -jar exactly.jar
Fehler: Zum Ausführen dieser Anwendung benötigte JavaFX-Runtime-Komponenten fehlen
(Error: to execute this app needed JavaFX-runtime-components missing)

I'm not a Java Developer, so I do not know how to proceed, to get the .jar file running on Ubuntu Linux. I tried some solutions I found in Internet (see below), but none worked out fine. Any help and advice are welcome!

My Environment: ubuntu 18.04.6 LTS

$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11 9-Ubuntu-0ubuntu2.18.04)
OpenJDK 64-Bit Server VM (build 11.0.11 9-Ubuntu-0ubuntu2.18.04, mixed mode, sharing)

The exactly directory:

(base) viejo@notebooka:~/java-anwendungen/exactly/dist$ ls -l
insgesamt 488
drwx------ 2 viejo viejo   4096 Nov 26 18:48 bundles
-rw-rw-r-- 1 viejo viejo    696 Nov 27 01:22 derby.log
-rwxrwxr-x 1 viejo viejo 236145 Sep 19  2017 exactly.jar
-rwxrwxr-x 1 viejo viejo 236352 Nov 26 19:27 exactly.run
-rwxrwxr-x 1 viejo viejo    198 Nov 26 19:14 launchExactly
drwx------ 2 viejo viejo   4096 Nov 26 18:48 lib
-rw-rw-r-- 1 viejo viejo      0 Nov 27 01:22 logfile.txt
-rw-rw-r-- 1 viejo viejo    207 Nov 26 19:24 stub.sh
drwxrwxr-x 5 viejo viejo   4096 Nov 27 01:22 ukexactly

note: The files exactly.run, launchExactly and stub.sh are created by me following the instructions in proposed solutions I found in Internet (see below) The files ukexactly, logfile.txt and derby.log were created by solution no.3.

The directory I found javafx (after installing it from Ubuntu repository):

(base) viejo@notebooka:/usr/share/openjfx/lib$ ls -l
insgesamt 6500
lrwxrwxrwx 1 root root      26 Feb 19  2019 javafx.base.jar -> ../../java/javafx-base.jar
lrwxrwxrwx 1 root root      30 Feb 19  2019 javafx.controls.jar -> ../../java/javafx-controls.jar
lrwxrwxrwx 1 root root      26 Feb 19  2019 javafx.fxml.jar -> ../../java/javafx-fxml.jar
lrwxrwxrwx 1 root root      30 Feb 19  2019 javafx.graphics.jar -> ../../java/javafx-graphics.jar
lrwxrwxrwx 1 root root      27 Feb 19  2019 javafx.media.jar -> ../../java/javafx-media.jar
-rw-r--r-- 1 root root     113 Feb 19  2019 javafx.properties
lrwxrwxrwx 1 root root      27 Feb 19  2019 javafx.swing.jar -> ../../java/javafx-swing.jar
lrwxrwxrwx 1 root root      25 Feb 19  2019 javafx.web.jar -> ../../java/javafx-web.jar
-rw-r--r-- 1 root root 6651322 Feb 19  2019 src.zip

The directory the symlinks point to:

(base) viejo@notebooka:/usr/share/java$ ls -l
insgesamt 10900
-rw-r--r-- 1 root root    5232 Feb 21  2019 gettext.jar
-rw-r--r-- 1 root root   35257 Apr 25  2018 java-atk-wrapper.jar
-rw-r--r-- 1 root root    2989 Sep 20  2018 java_defaults.mk
-rw-r--r-- 1 root root  749850 Feb 19  2019 javafx-base-11.jar
lrwxrwxrwx 1 root root      18 Feb 19  2019 javafx-base.jar -> javafx-base-11.jar
-rw-r--r-- 1 root root 2510966 Feb 19  2019 javafx-controls-11.jar
lrwxrwxrwx 1 root root      22 Feb 19  2019 javafx-controls.jar -> javafx-controls-11.jar
-rw-r--r-- 1 root root  127377 Feb 19  2019 javafx-fxml-11.jar
lrwxrwxrwx 1 root root      18 Feb 19  2019 javafx-fxml.jar -> javafx-fxml-11.jar
-rw-r--r-- 1 root root 4365220 Feb 19  2019 javafx-graphics-11.jar
lrwxrwxrwx 1 root root      22 Feb 19  2019 javafx-graphics.jar -> javafx-graphics-11.jar
-rw-r--r-- 1 root root  270551 Feb 19  2019 javafx-media-11.jar
lrwxrwxrwx 1 root root      19 Feb 19  2019 javafx-media.jar -> javafx-media-11.jar
-rw-r--r-- 1 root root  119827 Feb 19  2019 javafx-swing-11.jar
lrwxrwxrwx 1 root root      19 Feb 19  2019 javafx-swing.jar -> javafx-swing-11.jar
-rw-r--r-- 1 root root  714674 Feb 19  2019 javafx-web-11.jar
lrwxrwxrwx 1 root root      17 Feb 19  2019 javafx-web.jar -> javafx-web-11.jar
-rw-r--r-- 1 root root    5385 Nov 18 14:52 java_uno.jar
-rw-r--r-- 1 root root     368 Nov 18 14:52 juh-7.2.3.jar
lrwxrwxrwx 1 root root      13 Nov 18 14:52 juh.jar -> juh-7.2.3.jar
-rw-r--r-- 1 root root     356 Nov 18 14:52 jurt-7.2.3.jar
lrwxrwxrwx 1 root root      14 Nov 18 14:52 jurt.jar -> jurt-7.2.3.jar
-rw-r--r-- 1 root root    2613 Feb 21  2019 libintl.jar
-rw-r--r-- 1 root root 2191511 Nov 18 14:52 libreoffice-7.2.3.jar
lrwxrwxrwx 1 root root      21 Nov 18 14:52 libreoffice.jar -> libreoffice-7.2.3.jar
-rw-r--r-- 1 root root     356 Nov 18 14:52 ridl-7.2.3.jar
lrwxrwxrwx 1 root root      14 Nov 18 14:52 ridl.jar -> ridl-7.2.3.jar
-rw-r--r-- 1 root root     356 Nov 18 14:52 unoil-7.2.3.jar
lrwxrwxrwx 1 root root      15 Nov 18 14:52 unoil.jar -> unoil-7.2.3.jar
-rw-r--r-- 1 root root    4727 Nov 18 14:52 unoloader-7.2.3.jar
lrwxrwxrwx 1 root root      19 Nov 18 14:52 unoloader.jar -> unoloader-7.2.3.jar

My internet research lead to various proposed solutions, but none worked out:

Solution 1 create a bash script:

https://edencoding.com/runtime-components-error/#jar

see also: Convert .jar to an application for Windows, Linux & Mac

My bash file: launchExactly:

#!/bin/bash

java -jar exactly.jar --module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.fxml
$ ./launchExactly
Fehler: Zum Ausführen dieser Anwendung benötigte JavaFX-Runtime-Komponenten fehlen

Solution 2 append jar to a bash script:

https://coderwall.com/p/ssuaxa/how-to-make-a-jar-file-linux-executable

Create a bash file:

    #!/bin/sh
    MYSELF=`which "$0" 2>/dev/null`
    [ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"
    java=java
    if test -n "$JAVA_HOME"; then
        java="$JAVA_HOME/bin/java"
    fi
    exec "$java" $java_args -jar $MYSELF "$@"
    exit 1 

Append the .jar File:

cat stub.sh exaxtly.jar > exactly.run && chmod  x exactly.run

Also fails to start the jar:

$ exactly.run
exactly.run: Befehl nicht gefunden. (command not found)

$ ./exactly.run
Fehler: Zum Ausführen dieser Anwendung benötigte JavaFX-Runtime-Komponenten fehlen
(error: JavaFX-runtime-components needed to execute app missing)

Solution 3 start .jar with parameters on comandline:

How do I fix JavaFX runtime components are missing?

$ java --module-path /usr/share/openjfx/lib --add-modules ALL-MODULE-PATH -jar exactly.jar

Result:

$  java --module-path /usr/share/openjfx/lib --add-modules ALL-MODULE-PATH -jar exactly.jar
[EL Info]: 2021-11-27 01:22:39.859--ServerSession(255728718)--EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd
[EL Info]: connection: 2021-11-27 01:22:40.605--ServerSession(255728718)--file:/home/viejo/java-anwendungen/exactly/dist/exactly.jar_UKSipperflyPU login successful
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
    at uk.sipperfly.ui.Exactly.<init>(Exactly.java:107)
    at uk.sipperfly.ui.Exactly$83.run(Exactly.java:2971)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

The created derby.log file contains this information:

----------------------------------------------------------------
Mon Nov 29 12:59:52 CET 2021:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.11.1.1 - (1616546): instance a816c00e-017d-$
on database directory /home/viejo/java-anwendungen/exactly/dist/ukexactly with class loader java.net.URLClassLoader@$
Loaded from file:/home/viejo/java-anwendungen/exactly/dist/lib/derby.jar
java.vendor=Ubuntu
java.runtime.version=11.0.11 9-Ubuntu-0ubuntu2.18.04
user.dir=/home/viejo/java-anwendungen/exactly/dist
os.name=Linux
os.arch=amd64
os.version=5.4.0-90-generic
derby.system.home=null
Database Class Loader started - derby.database.classpath=''

The created logfile.txt is empty.

This attempt was the most promising, since at least the .jar started but it ended quickly in the above error message.

Note: A combination of solution 1 and 3 by changing the bash-script of solution 1 with the parameters from solution 3 resulted in the same errors of solution 3.

Now I am stuck and do not now how to proceed or if it is of any value to try to get the .jar file run under Linux.

CodePudding user response:

Your error seems to be related to Another issue & not with the Java dependencies. Kindly check any image file is missing while migrating the project or creating the jar file.

If possible could you please paste the code or screenshot of the code you are trying to run?

CodePudding user response:

You need an Instance of Java 8. The Newer verions don't have JavaFX libaries anymore.

  • Related