tonikelope / megabasterd

Yet another unofficial (and ugly) cross-platform MEGA downloader/uploader/streaming suite.
GNU General Public License v3.0
4.53k stars 595 forks source link

Immediate Crash on "java.sql.Connection.createStatement" for Java ARM64 for Apple Silicon #543

Open jetblackrx89 opened 1 year ago

jetblackrx89 commented 1 year ago

I tried installing both Java 17 and 20 from Oracle's site that's compiled specifically for ARM64 to be optimized for Apple Silicon based Macs. It seems they cause an immediate crash on "java.sql.Connection.createStatement" for some reason.

$ /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java -jar /Applications/MegaBasterd.jar
Jun 18, 2023 1:34:48 AM com.tonikelope.megabasterd.SqliteSingleton getConn
SEVERE: Error opening connection
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.sql.Connection.createStatement()" because "conn" is null
    at com.tonikelope.megabasterd.DBTools.setupSqliteTables(DBTools.java:33)
    at com.tonikelope.megabasterd.MainPanel.<init>(MainPanel.java:258)
    at com.tonikelope.megabasterd.MainPanel.main(MainPanel.java:136)

The only workaround is to default back to what Apple includes pre-installed on the system, which is still an x86_64 binary. You can do this by either uninstalling the Oracle JDK's or renaming their "info.plist" to something else.

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    17.0.7 (arm64) "Oracle Corporation" - "Java SE 17.0.7" /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
    1.8.371.11 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home