Snapping a simple jar app

Hi! I am trying to snap and old app of mine as a snap. A digital circuits simulator I wrote back in university. It is a simple snap. So, after reading a while I wrote this

name: vsim
base: core18
version: '0.9.0'
summary: Vsim is digital circuits simulator written in java
description: |
    Vsim is a digital circuits simulator written in java.
grade: devel
confinement: devmode

apps:
   vsim:
      command: bin/start.sh
      plugs: [home, x11]
parts:
  vsim:
    plugin: dump
    source: .
    organize:
    'build/libs/vsim.jar': bin/
    'start.sh': bin/
  build-packages:
    - ca-certificates
    - ca-certificates-java
  stage-packages:
    - openjdk-8-jre
    - openjdk-8-jre-headless
    - gtk2-engines-murrine
   - hicolor-icon-theme

But, when I try it, it starts to throw errors about “/etc/fonts/fonts.conf”

 java.io.IOException: Cannot run program "/usr/bin/xprop": error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at java.lang.Runtime.exec(Runtime.java:621)
	at java.lang.Runtime.exec(Runtime.java:451)
	at java.lang.Runtime.exec(Runtime.java:348)
	at org.GNOME.Accessibility.AtkWrapper.<clinit>(AtkWrapper.java:37)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at java.lang.Class.newInstance(Class.java:442)
	at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:805)
	at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:886)
	at javax.swing.JFileChooser.installShowFilesListener(JFileChooser.java:396)
	at javax.swing.JFileChooser.setup(JFileChooser.java:364)
	at javax.swing.JFileChooser.<init>(JFileChooser.java:343)
	at javax.swing.JFileChooser.<init>(JFileChooser.java:296)
	at cl.almejo.vsim.gui.SimWindow.<clinit>(SimWindow.java:142)
	at cl.almejo.vsim.Main.<init>(Main.java:44)
	at cl.almejo.vsim.Main.main(Main.java:79)
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
	at java.lang.ProcessImpl.start(ProcessImpl.java:134)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 18 more
Fontconfig warning: "/etc/fonts/fonts.conf", line 5: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/fonts.conf", line 6: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'version'
Fontconfig error: Cannot load config file from /etc/fonts/fonts.conf
Exception in thread "main" java.lang.Error: Probable fatal error:No fonts found.

It seems that is my systems fonts.conf file. Shouldnt it use the snap fonts.conf file?

What is the “official” way to snap a java jar app? I read about a jre plugin, but it seems to be deprecated.

(In the future I plan to use the gradle plugin, maybe it solves my problem, but what if I want to snap a simple jar?)

Thanks

Take a look at the repo for shattered-pixel-dungeon. That’s how I bundled a jar.

1 Like

Thanks @popey, I read the snap and now I have one big question :thinking:

I used helpers a lot time ago snapping a qt5 app. Buy I thought it could be “too much” and tryed to do without it.

Also, I tryed the gnome extension 3.28 and IT WORKED! , bugt it I thought that it was too much too. But after reading the snap of shattered pixel dungeon, I read in the “snapcraft helpers” the following:

We are currently in the process of moving most of the functionality of the desktop helpers to Snapcraft Extensions.

So, maybe the right directions is to use the gnome extension?

(If that is true, I should move my old qt5 snap to use kde-neon?)

Thanks for listening and teaching me

Well, I would, but that snap uses the gtk2 helper, and as far as I am aware the snapcraft GNOME extension only supports GTK3 / GNOME 3.x. I may be wrong, but I doubt there is any plan to create a gtk2/GNOME 2.x extension. However, I probably could and should migrate that snap. I’ll put it on my to-do list and look at later.

The kde-neon extension will probably become the recommended way to snap Qt applications, but at the moment the extension can only be used by the KDE project itself until this auto-connection is fixed: Allow Global auto connect for kde-frameworks-5-core18

The kde-neon extension however, still has some disadvantages over the Qt5 desktop helpers see this post for more info.

The gnome-* extensions only support GTK 3, but I wouldn’t rule out a GTK+ 2 extension in the future. However, that might take a while and until that happens, the GTK+ 2 applications page is the recommended method.

Also see Desktop applications for an overview of how to snap desktop applications.

1 Like

Thanks both for the time

So, I read again the java swing page (the one with freeplane example) and they use the gnome extension, so I will use it.

For my qt app I will use the desktop helper and wait for the kde-neon to be ready

Maybe, the docs about java apps should mention it, that the recommended way to run a java swing app is to use the gnome-extension (now it seems an example). Ubuntu is a gnome distribution after all.

For Java swing apps it depends; some apps such as Arduino only support GTK+ 2 integration. Those look most “native” when you use GTK2 desktop helpers. Some apps support GTK 3 integration and some don’t support any integration at all.

  • No integration supported: Gnome extension (freeplane example)
  • GTK3 integration supported: Gnome extension
  • GTK 2 integration supported: desktop helpers. (Arduino example)

Where would you like to see these recommendations? On the Desktop applications page, on the tutorial/examples page or on another page? If you have any other tips to improve the docs, let me know!

Thanks. It is a lot more clear to me. My app is not integrated with gnome, but using it made it works immediately

I think that those recommendations should be in the same page as the (freeplane example)[Java applications] . I get to that page from Desktop applications looking for Java Swing and never saw the gtk2/gtk3 explanation. A lot of java developers will go to the freeplane page at first look how to package.

I love to see how snaps evolve.

1 Like