Sound cannot be play

I am trying to play the sound in my,but when I start the game it show out a warning:

Jan 22, 2020 6:03:04 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.2-stable

  • Branch: HEAD
  • Git Hash: 8291d61
  • Build Date: 2019-07-27
    Jan 22, 2020 6:03:04 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
    INFO: LWJGL 2.9.3 context running on thread jME3 Main
  • Graphics Adapter: null
  • Driver Version: null
  • Scaling Factor: 1
    Jan 22, 2020 6:03:04 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
    INFO: OpenGL Renderer Information
  • Vendor: Intel Open Source Technology Center
  • Renderer: Mesa DRI Intel® Sandybridge Desktop
  • OpenGL Version: 3.0 Mesa 19.0.8
  • GLSL Version: 1.30
  • Profile: Compatibility
    Jan 22, 2020 6:03:05 PM com.jme3.asset.AssetConfig loadText
    WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
    Jan 22, 2020 6:03:05 PM initOpenAL
    INFO: Audio Renderer Information
  • Device: OpenAL Soft
  • Vendor: OpenAL Community
  • Renderer: OpenAL Soft
  • Version: 1.1 ALSOFT 1.15.1
  • Supported channels: 64
  • AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
    Jan 22, 2020 6:03:05 PM initOpenAL
    WARNING: Pausing audio device not supported.
    Jan 22, 2020 6:03:05 PM initOpenAL
    INFO: Audio effect extension version: 1.0
    Jan 22, 2020 6:03:05 PM initOpenAL
    INFO: Audio max auxiliary sends: 4
    Jan 22, 2020 6:03:05 PM handleError
    SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
    at mygame.Main.simpleInitApp(
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(

Because the music is write in another class,so I create a private Sound sound; to call the method that I had write in the Here is my code to call it:


Does anything wrong here ?

We would need to see the code that created the audionode and plays it. The line that throws the nullpointer is null. Nullpointers are amongst the easiest problems to solve.

As Jay says, this is where your bug is:

Here is the code that I create it:

import com.jme3.asset.AssetManager;
import java.util.Random;

 * @author simon
public class Sound {
    private AudioNode music;
    private AudioNode[] shots;
    private AudioNode[] explosions;
    private AudioNode[] spawns;

    private AssetManager assetManager;

public Sound(AssetManager assetManager) {
    this.assetManager = assetManager;
    shots = new AudioNode[4];
    explosions = new AudioNode[8];
    spawns = new AudioNode[8];


private void loadSounds() {
    music = new AudioNode(assetManager,"Sounds/Music.ogg");

    for (int i=0; i<shots.length; i++) {
        shots[i] = new AudioNode(assetManager,"Sounds/shoot-0"+(i+1)+".wav");

    for (int i=0; i<explosions.length; i++) {
        explosions[i]  = new AudioNode(assetManager,"Sounds/explosion-0"+(i+1)+".wav");

    for (int i=0; i<spawns.length; i++) {
        spawns[i]  = new AudioNode(assetManager,"Sounds/spawn-0"+(i+1)+".wav");

public void startMusic() {;

public void shoot() {
    shots[new Random().nextInt(shots.length)].playInstance();

public void explosion() {
    explosions[new Random().nextInt(explosions.length)].playInstance();

public void spawn() {
    spawns[new Random().nextInt(spawns.length)].playInstance();

The code is:


Did I using wrong method or what ?

sound is null

…you haven’t even shown us that code. The bug is in the code you didn’t post. The one that should have set “sound” to something and didn’t.

Did I using wrong method or what ?

yes, you use method on null value.

null.startMusic(); will not work for sure.

its most probably in mygame.Main.simpleInitApp( line, so this is your code issue.

we cant know what you have in this line, its like “guess what i think”
so you want us to guess what is in mygame.Main.simpleInitApp

private Sound sound;

@pspeed @oxplay2
Did you say the ‘code’ is this ?
I just type it in my, and the line 78 is the sound.startMusic;

And you guys say the Sound is null maybe because I don’t add new to it ?

Yes, sound is null because you’ve never set it to anything.

Learning to program in Java is like learning to ride a bike.
Learning to program 3D games is like learning to shave with a straight-razor.

Trying to do both at once is extremely painful.

1 Like
private Sound sound = new Sound;
private Sound sound = Sound.class;

I try to set it like above, but both of it goes wrong.
Had any another way to set Sound up ?

Without understanding how to code in Java, trying random things isn’t going to be very productive.

I recommend that you run through some basic Java tutorials until you have a better grasp of the language and how to program. The rest of your journey will go much more easily.

All right , I will do it. And thanks for all of your guy’s reply. :smiley:

1 Like

Do not be discourage. The error is very obvious and giving you the answer would not be of help, you would just lurch onto the next problem.

Try this,

and this one, although old it’s written by a very good author, Doug Lowe,

New or used.

Anyway, they are easy reads and will get you going.