nus-oss / AB3-J17

:ab::three: Address Book sample application (Level 3)
https://se-education.org/addressbook-level3
MIT License
0 stars 16 forks source link

[Project A][Linux, MacSilicon, Win10][brein62] Upgrade to Java 17 #4

Closed brein62 closed 2 months ago

brein62 commented 2 months ago

Migrate AB3 to Java 17

Description

This PR migrates the AddressBook-Level3 (AB3) application to Java 17. Due to compatibility issues facing Apple Silicon (M1 Mac and above) devices when importing the JavaFX dependency, this PR adds support for Apple Silicon while also ensuring cross-platform compatibility with other operating systems (Windows 10 and Linux/Ubuntu 24.04 LTS).

Additionally, the JavaFX version is updated to the latest version of JavaFX 17 (JavaFX 17.0.11).

Devices Used

  1. M1 MacBook Air 2020

    • OS used: Apple Silicon/ARM64 running on MacOS 13.3 Ventura
    • JDK distribution: Oracle OpenJDK v17.0.11
  2. Windows 10 PC

    • OS used: Windows 10
    • JDK distribution: Oracle OpenJDK v17.0.10
  3. Linux VM running on top of Windows 10 PC

    • OS used: Ubuntu 24.04 LTS running on VirtualBox
    • JDK distribution: Oracle OpenJDK v17.0.11

Links to all JAR files created: https://github.com/brein62/AB3-J17/releases/tag/milestone-1

Process and Approaches

Possible Compatibility Issues?

Possible lack of support for Macs with Intel chip without multiple releases

I encountered an issue where the order of the dependency imports matter when running on my M1 Mac:

dependencies {
    String javaFxVersion = '17.0.11'
    ...
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac-aarch64'
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
    ...
}

Swapping the imports of mac to be above mac-aarch64 causes JARs created by other OSes to not work on my M1 Mac since the JAR somehow uses the Intel Mac version of JavaFX instead resulting in an error. As a result, there may be an issue with this running on Intel Macs, which needs to be tested.

A Reddit thread from 2 years old seemed to suggest that only one architecture per OS is supported for JavaFX applications due to how JavaFX handles OS-native files internally (and thus likely Intel Macs would not work). If this is the case, it is likely that future applications would require two separate JAR releases (one for Windows/Mac/Linux x64 and one for Apple Silicon).

damithc commented 2 months ago

@brein62 We faced this ARM vs Intel issue even with Java 11 but eventually we figured using the prescribed Azul JDK removed the need for adding mac-aarch64 to the Gradle file. I'm hoping we can do something similar with Java 17. Can you try the JDK version suggestion in https://github.com/nus-oss/AB3-J17/pull/6 and report findings?

damithc commented 2 months ago

@brein62 Can you post a JAR file created on Linux, without the mac-aarch64 in the build.gradle?

brein62 commented 2 months ago

@damithc Here is the link to the release containing the three JARs created on Linux using the 17.0.11-oracle, 17.0.11.fx-zulu and 17.0.11.fx-librca JDKs after removing the mac-aarch64 portion in build.gradle: https://github.com/brein62/AB3-J17/releases/tag/linux-testing

I did some tests on my M1 MacBook Air and all three JARs run on my MacBook when running the 17.0.11.fx-zulu and 17.0.11.fx-librca Java versions, but none of the JARs work for 17.0.11-oracle (as expected).

itstrueitstrueitsrealitsreal commented 2 months ago

Tested on Mac Silicon with JDK-FX 17.0.11.fx-zulu, and working.

Steps followed:

  1. Downloaded the JAR file from the PR.
  2. Switched to JDK-FX 17.0.11.fx-zulu using SDKMAN.
  3. Ran the JAR file using java -jar Ubuntu24.04LTS-brein62.jar and java -jar MacSilicon-brein62.jar
  4. Performed a smoke test to verify basic functionality.

Results:

Everything is functioning as expected.

Screenshots:

jyue487 commented 2 months ago

Tested on Mac Silicon with JDK-FX 17.0.11.fx-zulu, and working.

Steps and results are identical to above.

teoks0199 commented 2 months ago

Tested on Windows 11, and working.

Steps followed:

  1. Downloaded the JAR file from the PR.
  2. Ran the JAR file using java -jar Ubuntu24.04LTS-brein62.jar.
  3. Performed a smoke test to verify basic functionality.

image

bennyLCK commented 2 months ago

Smoke-Tested on Windows 11, using Oracle OpenJDK version 17.0.10 on Windows Powershell Terminal running the java -jar Ubuntu24.04LTS-brein62.jar command, basic commands were run to ensure full functionality of the application.

image

baskargopinath commented 2 months ago

Tested on Mac Silicon with JDK-FX 17.0.11.fx-zulu, and working.

Steps followed: Downloaded the JAR file from the PR. Switched to JDK-FX 17.0.11.fx-zulu Ran the JAR file using java -jar Ubuntu24.04LTS-brein62.jar Performed a smoke test to verify basic functionality. Results: Everything is functioning as expected.

Screenshots:

image
aureliony commented 2 months ago

Tested on Ubuntu 22.04.4 LTS with zulu jdk 17.0.11. JARs are working fine.

Steps followed: Downloaded the JAR file(s) from the release. Ran the JAR file(s) using java -jar MacSilicon-brein62.jar, Ubuntu24.04LTS-brein62.jar and java -jar win10-brein62.jar. Performed a smoke test to check basic functionality.

Results: Everything is functioning as expected.

Screenshot from 2024-07-06 19-31-43 Screenshot from 2024-07-06 19-35-39 Screenshot from 2024-07-06 19-36-16

gongg21 commented 2 months ago

Tested on MacSilicon with JDK-FX 17.0.11.fx-zulu, and working fine. Switched using SDKMAN, ensure it is 17.0.11.fx-zulu, note the .fx suffix. Add/Delete command tested, works. Help command tested, works. Ran JAR file using java -jar <filename>.

Using Ubuntu24.04LTS-brein62.jar (i.e. inclusive of mac-aarch64 lines in build.gradle):

Screenshot 2024-07-07 at 5 45 46 PM

Using addressbook-linux-zulu.jar:

Screenshot 2024-07-07 at 5 47 10 PM
Carlintyj commented 2 months ago

Tested on Mac (Silicon) using JDK-FX 17.0.11.fx-zulu and working.

Downloaded the JAR release, ran the jar file using java -jar Ubuntu24.04LTS-brein62.jar Performed smoke test to check functionality.

Screenshot 2024-07-07 at 7 28 49 PM
drustanyjt commented 2 months ago

Tested on Linux (Ubuntu 22.04) using OpenJDK 17.0.11. Working.

Steps taken:

  1. Downloaded release
  2. Ran jar file using java -jar Ubuntu24.04LTS-brein62.jar
  3. Tested with basic commands

image

jedkohjk commented 2 months ago

Tested all 3 jar files on Windows 11 and working.

Steps I followed:

  1. Downloaded the JAR file from the release.
  2. Ran java -jar Ubuntu24.04LTS-brein62.jar.
  3. Tested some basic commands.
  4. Closed the program.
  5. Ran java -jar MacSilicon-brein62.jar.
  6. Tested some basic commands.
  7. Closed the program.
  8. Ran java -jar win10-brein62.jar.
  9. Tested some basic commands.

Screenshot

Screenshot

Screenshot

damithc commented 2 months ago

Closing, as the migration was done in https://github.com/nus-oss/AB3-J17/commit/fe805d8553bbc329644371a6e732a8317ea6686f