nus-cs2103-AY2122S2 / forum

13 stars 1 forks source link

IP: Classes were loaded from unnamed module #189

Closed Gernene closed 2 years ago

Gernene commented 2 years ago

Hi everyone! My IP is pretty much working as intended, but the jar is failing smoke tests because of this warning:

Gernenes-MacBook-Pro:ip gernene$ java -jar ip-all.jar
Feb 28, 2022 10:52:29 AM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @57397011'

I'm using MacOS and managing JavaFX with gradle. Here's my gradle.build for reference

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This is a general purpose Gradle build.
 * Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.3.3/samples
 */

plugins {
    id 'java'
    id 'application'
    id 'checkstyle'
    id 'com.github.johnrengelman.shadow' version '5.1.0'
    id 'org.openjfx.javafxplugin' version '0.0.10'
}

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

application {
    mainClassName "duke.Launcher"
}

checkstyle {
    toolVersion = '8.29'
}

test {
    useJUnitPlatform()
}

javafx {
    version = "17"
    modules = [
        'javafx.base',
        'javafx.controls',
        'javafx.fxml',
        'javafx.graphics',
        'javafx.media',
        'javafx.swing',
        'javafx.web'
    ]
}

dependencies {
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0'
    testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0'
}

repositories {
    mavenCentral()
}

As you can see above, I've even tried importing all the javafx module, but I'm still getting the error. Does anyone know what to do? Thank you!

yusufaine commented 2 years ago

I'm not sure if changing the version of javafx to 11 would help -- I had encountered the same thing and got that warning as well, but resorted to specifying all the javafx stuff under dependencies such as:

dependencies {
    String javaFxVersion = '11'

    implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
    implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
    implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
    implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'

    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0'
    testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0'
}
Gernene commented 2 years ago

@yusufaine Looks like that worked! Unfortunately, I'm now having a problem with text-wrapping on the dialogue box. I used the HBox.hgrow="ALWAYS" fxml property, but it doesn't seem to work in JavaFX 11.

yusufaine commented 2 years ago

@Gernene is the issue similar to #112?

Gernene commented 2 years ago

@yusufaine Exact same issue! I tried implementing this solution, but no success. :(

yusufaine commented 2 years ago

@Gernene just 2 follow-up questions:

  1. Looking at my suggestion in the linked post again, I realised that I could make the change in the DialogBox constructor. Could you perhaps add a dialog.setMinHeight(Region.USE_PREF_SIZE); around line 38 of your DialogBox.java?
  2. If that doesn't fix it, could you also try adding a dialog.setWrapText(true) around line 38 as well?
Gernene commented 2 years ago

@yusufaine Still not working. :( I even tried setting a minHeight on the HBox itself.

yusufaine commented 2 years ago

@Gernene At a glance, I noticed that your DialogBox.fxml has a HBox.hgrow here as well, which I hadn't set on mine, could that be the issue?

Gernene commented 2 years ago

@yusufaine Same thing. :(

Gernene commented 2 years ago

@yusufaine Thank you for all the help! I finally found a workaround:

AY19/20 S1 issue 98