好的,所以我几乎无法使用 Java 和 Swing 在 Google 上搜索“Snap”、“Snappy”或“Snapd”这些术语。但我想知道是否可以使用 Snap 运行 Java Swing 应用程序。
当我安装生成的 snap 然后尝试运行该应用程序时,它立即返回而没有任何输出。
我正在使用 x11 插头/接口。
作为一个快速而简单的测试,我还使用了与使用简单的“hello world”Swing 源修改的snapcraft 示例源相关联的 java-hello-world 。
package oata;
import javax.swing.*;
public class HelloWorld {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:好的,所以重启修复了我的关闭 snapd/ubuntu-core 状态问题。我现在回到没有 GUI,没有输出。我已经分叉了 snapcraft 并修改了 demo 的示例。
当前捕捉接口输出:
matta@mirkwood:/work/Dev/snapcraft/examples/java-hello-world$ snap interfaces
Slot Plug
:firewall-control -
:home -
:locale-control -
:log-observe -
:mount-observe -
:network -
:network-bind -
:network-control -
:network-observe -
:opengl -
:snapd-control -
:system-observe -
:timeserver-control -
:timezone-control -
:unity7 -
:x11 java-hello-world
Run Code Online (Sandbox Code Playgroud)