我想在我的系统中包含Java GUI支持,该系统仅支持wayland后端。我试图包含OpenJDK-7-jre包,但似乎有X11依赖。 我成功地编译了'Openjre-8'包,并将其包含在我的图像中。但是,它只能运行没有GUI的Java应用程序。当我尝试运行任何基于JAVA SWING API的GUI程序时,我收到以下错误:
class Generic a where
type Rep a -- with the expectation that Rep is formed of tuples and Eithers
toRep :: a -> Rep a
fromRep :: Rep a -> a
-- your example
instance Generic A where
type Rep A = Either (Rep B) (Rep C, Rep D)
toRep (A1 b) = Left (toRep b)
toRep (A2 c d) = Right (toRep c, toRep d)
fromRep (Left b) = A1 (fromRep b)
fromRep (Right (c, d)) = A2 (fromRep c) (fromRep d)
-- plus instances for B, C, D, etc
是否可以在Wayland上运行Java GUI程序?我们怎么做?
答案 0 :(得分:6)
我发现这个问题同时想知道同样的事情:我有一个Java Swing应用程序,我想在Wayland上本地运行。我不知道这是否可能,而且缺乏其他答案似乎表明事实并非如此。
但是,您绝对可以在XWayland下运行Swing应用程序,并在您首选的Wayland合成器下运行 。您可能会发现它足以满足您的需求。至少在GNOME 3合成器的初始测试中,它对我来说效果很好。
编辑:在继续我的搜索时,我发现Wayland社区已经在他们的邮件列表中以相同的方式回答了您的问题,以及其他上下文。为了节省其他读者的麻烦,本文总结了截至2016年8月的情况:https://lists.freedesktop.org/archives/wayland-devel/2016-August/030832.html
答案 1 :(得分:1)
我使用 cacio-wayland @Zubzub 作为对另一个答案的评论解决了这个问题。
由于我想使用的程序 (IntelliJ IDEA) 需要 JDK >=11,因此我必须对 cacio-shared 子目录进行一些更改,并相应地调整 cacio-wayland 以在 JDK11 上运行:
https://github.com/petabyteboy/caciocavallo/commit/81d3254699f6caaa1e9957cae47703e0b18de870
您可以克隆我的存储库、构建库并使用它们来启动您的应用程序。在这个例子中,我启动了 JD-GUI:
# make sure you have the following things installed: openjdk jdk11, cairo, wayland, libxkbcommon, maven, git
git clone https://github.com/petabyteboy/caciocavallo
cd caciocavallo
mvn clean install
# it may fail to generate javadocs, but as long as cacio-wayland/target/cacio-wayland-1.10-SNAPSHOT.jar is generated it should be fine
# the generated native library needs to be renamed to be found at runtime
mkdir natives
cp cacio-wayland/target/nar/cacio-wayland-1.10-SNAPSHOT-amd64-Linux-gpp-jni/lib/amd64-Linux-gpp/jni/libcacio-wayland-1.10-SNAPSHOT.so natives/libcacio-wayland.so
java \
-cp $PWD/cacio-shared/target/cacio-shared-1.10-SNAPSHOT.jar:$PWD/cacio-wayland/target/cacio-wayland-1.10-SNAPSHOT.jar:/usr/share/jd-gui/jd-gui-1.6.6.jar \
-Dawt.toolkit=net.java.openjdk.cacio.wayland.WaylandToolkit \
-Djava.awt.graphicsenv=net.java.openjdk.cacio.wayland.WaylandGraphicsEnvironment \
-Djava.library.path=$PWD/natives \
org.jd.gui.App
如果它在您的 Wayland 合成器中导致 SIGSEGV 崩溃,请在 Weston 中尝试。
答案 2 :(得分:0)
这是可能的。 AWT代表“抽象”窗口工具箱。 AWT有许多扩展,对等点是QT或GTK,而不是默认的JDK。
Qt: https://cvs.savannah.gnu.org/viewvc/classpath/classpath/gnu/java/awt/peer/qt/
Gtk: https://cvs.savannah.gnu.org/viewvc/classpath/classpath/gnu/java/awt/peer/gtk/
请注意,这些来源较旧,可能需要进行一些修订才能与最新的JDK一起使用。