HumbleUI / JWM

Cross-platform window management and OS integration library for Java
Apache License 2.0
571 stars 46 forks source link

linux using jwm WindowX11._nMake() verror #239

Closed cyz1901 closed 2 years ago

cyz1901 commented 2 years ago
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'long io.github.humbleui.jwm.WindowX11._nMake()'
    at io.github.humbleui.jwm.WindowX11._nMake(Native Method)
    at io.github.humbleui.jwm.WindowX11.<init>(WindowX11.java:15)
    at io.github.humbleui.jwm.App.makeWindow(App.java:47)

code:

public class HelloWorld {
    public static void main(String[] args) {
        try {
            Window window = App.makeWindow();
        }catch(Exception e) {
            System.out.println(111);
            e.printStackTrace();
        }
    }

}
OS: Manjaro Linux x86_64 
Kernel: 5.15.65-1-MANJARO

I think the problem probably is in WindowX11.cc

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_jwm_WindowX11__1nMake
  (JNIEnv* env, jclass jclass) {
    std::unique_ptr<WindowX11> instance = std::make_unique<WindowX11>(env, jwm::app.getWindowManager());
    if (instance->init()) {
        return reinterpret_cast<jlong>(instance.release());
    }
    return 0;
}
dzaima commented 2 years ago

You're supposed to do all window operations from within the App.start lambda, i.e.

public class HelloWorld {
    public static void main(String[] args) {
        App.start(() -> {
            Window window = App.makeWindow();
        });
    }
}
cyz1901 commented 2 years ago

You're supposed to do all window operations from within the App.start lambda, i.e.

public class HelloWorld {
    public static void main(String[] args) {
        App.start(() -> {
            Window window = App.makeWindow();
        });
    }
}

Thank you! I think we should update the tutorial https://github.com/HumbleUI/JWM/blob/main/docs/Getting%20Started.md

<dependency>
    <groupId>io.github.humbleui</groupId>
    <artifactId>jwm</artifactId>
    <version>0.3.1</version>
</dependency>

version 0.3.1 don't have lambad for start() function And i update version to 0.4.7 make code run success.