Ubuntu – Developing a Snap package for a project using Java/Swing

javasnap

OK, so I can barely Google anything with the terms "Snap", "Snappy", or "Snapd" with Java and Swing. But I would like to know if it is possible to run a Java Swing application using Snap.

When I install my generated snap and then try to run the application, it immediately returns without any output.

I am using the x11 plug/interface.

As a quick and simple test, I am also using the java-hello-world associated with the snapcraft example source modified with a simple "hello world" Swing source.

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();
            }
        });
    }
}

EDIT:
OK, so a reboot has fixed my off snapd/ubuntu-core state problem.
I am now back to no GUI, no output. I have forked snapcraft and modified the example for demo.

Current snap interfaces output:

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

Best Answer

Related Question