1

i've been trying to solve this for hours and hours now. I have a java program which i exported as a .jar. The jar works fine, but i wanted to a) bundle it to a MacOS application (.app) b) include the JRE in the app. I used packr https://github.com/libgdx/packr to achieve this. however, the app made by packr has some troubles. i get this when i start it:

    Exception in thread "Thread-1" java.lang.NoClassDefFoundError: com/sun/media/sound/JDK13Services
at javax.sound.sampled.AudioSystem.getProviders(AudioSystem.java:1629)
at javax.sound.sampled.AudioSystem.getAudioFileReaders(AudioSystem.java:1404)
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1105)
at Audio.AudioPlayer.<init>(AudioPlayer.java:11)
at GameState.MenuState.<init>(MenuState.java:45)
at GameState.GameStateManager.loadState(GameStateManager.java:51)
at GameState.GameStateManager.<init>(GameStateManager.java:46)
at Main.GamePanel.init(GamePanel.java:58)
at Main.GamePanel.run(GamePanel.java:63)
at java.lang.Thread.run(Thread.java:744)

looking at the stack trace, it apparently has something to do with the audio IO; this assumption is also consistent with the impression that the program seems to run until audio ist used; but i just can't figure out what to change since the .jar works perfectly.

the configuration file for packr loooks like this:

     {
    "platform": "mac",
"jdk": "/Users/.../bounces/openjdk-1.7.0-u45-unofficial-icedtea-2.4.3-macosx-x86_64-image.zip",
"executable": "Moths",
"classpath": [
    "/Users/.../bounces/Moths_JRE_1.7_beadz.jar"
],
"mainclass": "Main.Game",
"vmargs": [

],
"resources": [

],
"minimizejre": "soft",
"output": "/Users/.../bounces/Moths.beadz.app",
"icon": "/Users/.../bounces/icon.icns"
    }

Any ideas?

Update: Solution It's got nothing to do with the audio I/O, in fact the solution is much simpler: packr has an optional minimizing routine which deletes unnecessary parts of the JRE before packing it, in order to make the app bundle as small as possible. Unfortunately, com.sun.media is one of the packages that are deleted. Solution: disable minimize option before packing.

1 Answers1

0

com/sun/media/sound/JDK13Services resides in rt.jar For MacOS it is called classes.jar and located under /System/Library/Frameworks/<java_version>/Classes. Make sure you have included it in the classpath

sidgate
  • 14,650
  • 11
  • 68
  • 119
  • OK, so on a Mac, the JDK13Services class is in /System/Library/Frameworks//Classes/classes.jar, while in the JRE i included in the app, it's in /lib/rt.jar. – MrCandlelLight Oct 15 '16 at 00:17
  • sorry, didn't want to post already :( ...how do i tell my app to load it from /lib/rt.jar? Or am i completely missing your point. – MrCandlelLight Oct 15 '16 at 00:19