Very first snapcraft.yaml configuration for Java GUI application

I developed a java GUI app and I’d like to share it on Snapcraft. My app is open source (MIT license) and available on GitHub: morse-code. I can’t figure out how to “tell” to the ‘snapcraft.yalm’ file that everything should start from the MVCMain.java file. Anyone could help me?

My $0.02 –

The easiest way to create a snap from a java app in my experience is to make it a maven build. This way, snapcraft automatically knows how to build your app and where to find “main.” The idea is that if you set up your project to build in a more-or-less standard way, snapcraft can make reasonable assumptions about where to find things.

I would start here: https://snapcraft.io/docs/java-applications. (Highlighting gradle in this doc is a bit of an odd choice in my opinion since maven is more widely used, but it covers the basics.) The docs for the maven plugin are a bit light, but here they are: https://snapcraft.io/docs/maven-plugin.

Next, take a look at my java game for an example of how to build a snap from a maven project. https://github.com/jsseidel/jgalaxian. I don’t claim that my way is the best or even right way, but it works :slight_smile:

I would take that example and build it locally so you can also get a better understanding of how to debug snapcraft builds. Debugging these builds isn’t too hard once you get the basic concepts down. @popey has a couple of great videos about this. Here is one: https://www.youtube.com/watch?v=DtZySQgBxmM.

Hope that at least gets you started.

jgalaxian sound no longer plays!!

there seems to be some bug in snap,
no matter which version of java I use in my game snake-on-the-chase, 8 or 11, sound doesn’t play
previously, there was the following error with java 11 with core18 :
Exception in thread “Thread-6” java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian is supported.

so I used core with java 8 , and sound used to work perfectly, but now even this setting doesn’t work, it doesn’t even show the error.

when I use java 11 with core18 it gives the same error:
Exception in thread “Thread-6” java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian is supported.

while searching for solution, I came across this page, I had jgalaxian installed, the sound used to play perfectly, but since few months its not playing, I compared your snapcraft.yaml file with mine, turns out, had same settings as I had used for snake-on-the-chase game, java 8 with core with pulseaudio.

but strangely , it no longer works!! would you verify if its only for me or its the same on your computer!!

Whelp, I knew this day was coming. I had experimented previously with building jgalaxian on new versions of snap and saw the no sound problem, but I didn’t have the patience or time to deal with it and still don’t.

Note that sound works for jgalaxian compiled and run locally on 20.04. I will probably just unpublish it and repackage as a deb. It’s much easier.

So fortunately, the JGalaxian snap downloaded and installed from the snap store still has sound for me on an updated 20.04. I guess I will keep it published until that is no longer the case. Not sure when I will find time to track this down, tho.

Here are some hints:

https://stackoverflow.com/questions/6884974/why-do-i-get-java-lang-illegalargumentexception-no-line-matching-interface-sour

I use AudioCue and AudioMixer, so I might try using java.mediax instead of java.sound. I think I could manually install AudioCue and AudioMixer and replace the relevant imports.

Also, here’s a link to the other topic on this:

the link you provided was created by me, I am facing the same problem in my game snake-on-the-chase , came across your game and noticed it used java and thought you might have had any success!!

Oh, I knew that. I just wanted to point to it in this thread. BTW – Did you see that @popey suggested replacing pulseaudio with audio-playback in the plugs section? I’m trying it now.

Fixed. Long winded explanation here: Java application shows and error when trying to play sound