[SOLVED] Can't run compiled JAR Java.nullpointerException [jMonkeyEngine SDK 3.1, JDK 8]


#1

Hey! I am learning how to use the jMonkeyEngine. But when I’m trieing to run the JAR from the projec’s dist Folder I am getting this error:

Exception in thread “main” java.lang.ExceptionInInitializerError
at com.jme3.system.AppSettings.(AppSettings.java:150)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:113)
at de.EmeldemelTV.Hallospielewelt.Main.main(Main.java:12)
Caused by: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.jme3.system.JmeVersion.(JmeVersion.java:51)
… 3 more

In the Engine itself It runs perfect.
Sorry for my bad English


#2

What are the lines of code that are causing the exception doing? Reading an external file? What are the lines of code that are causing the exception.


#3

Seems like maybe his jme jar files are missing their version info somehow. Hard to say how OP got to this point, though


#4

I translated it a bit:

package de.EmeldemelTV.Hallospielewelt;
import com.jme3.app.Application;

import com.jme3.app.SimpleApplication;

import com.jme3.app.state.AbstractAppState;

import com.jme3.app.state.AppStateManager;

import com.jme3.asset.AssetManager;

import com.jme3.bounding.BoundingBox;

import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;

import com.jme3.bullet.control.CharacterControl;

import com.jme3.bullet.control.RigidBodyControl;

import com.jme3.input.ChaseCamera;

import com.jme3.input.FlyByCamera;

import com.jme3.input.InputManager;

import com.jme3.input.KeyInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;

import com.jme3.math.Vector3f;

import com.jme3.renderer.Camera;

import com.jme3.scene.Geometry;

import com.jme3.scene.Node;

import com.jme3.scene.Spatial;





public class Level01State extends AbstractAppState {



    private final Node rootNode;

    private BulletAppState bulletAppState;

    

    private final Node localRootNode = new Node("Level 1");

    private final AssetManager assetManager;

    private final InputManager inputManager;

    private final FlyByCamera flyByCamera;

    private final Camera camera;

    private ChaseCamera chaseCam;

    private CharacterControl playerControl;

    

  

    private final Vector3f playerWalkDirection = new Vector3f(0, 0, 0);

    



    private boolean left = false, right = false, up = false, down = false;

    

    public Level01State(SimpleApplication app) {

        rootNode = app.getRootNode();

        assetManager = app.getAssetManager();

        inputManager = app.getInputManager();

        

      

        flyByCamera = app.getFlyByCamera();

        

      

        camera = app.getCamera();

    }

    

    @Override

    public void initialize(AppStateManager stateManager, Application app) {

        super.initialize(stateManager, app);

        

        

        bulletAppState = new BulletAppState();

        

        bulletAppState.setDebugEnabled(true);

      

        stateManager.attach(bulletAppState);

        

        rootNode.attachChild(localRootNode);

        

       

        Spatial scene = assetManager.loadModel("Szenen/LevelEins.j3o");



       

        localRootNode.attachChild(scene);

        

        

     

        Geometry player = (Geometry) localRootNode.getChild("Player");

        

        

        BoundingBox boundingBox = (BoundingBox) player.getWorldBound();

        

        

        float radius = boundingBox.getXExtent();

        float height = boundingBox.getYExtent();

        

     

        CapsuleCollisionShape shape = new CapsuleCollisionShape(radius, height);



       

        playerControl = new CharacterControl(shape, 1.0f);

        

     

        player.addControl(playerControl);

        

      

        bulletAppState.getPhysicsSpace().add(playerControl);

        

        

        Geometry floor = (Geometry) localRootNode.getChild("Bodenrofl");
        Geometry box = (Geometry) localRootNode.getChild("Box");
        

    
        RigidBodyControl boxcontrol = box.getControl(RigidBodyControl.class);
        RigidBodyControl floorControl = floor.getControl(RigidBodyControl.class);

        

       
        
        bulletAppState.getPhysicsSpace().add(floorControl);

        

        inputManager.addMapping("Pause", new KeyTrigger(KeyInput.KEY_P));

        inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));

        inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));

        inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));

        inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));

        inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_SPACE));

        inputManager.addListener(actionListener, "Pause", "Up", "Down", "Left", "Right", "Jump");

        

        

        flyByCamera.setEnabled(false);

        chaseCam = new ChaseCamera(camera, player, inputManager);

        chaseCam.setInvertVerticalAxis(true);

    }

    

    private final ActionListener actionListener = new ActionListener() {

        @Override

        public void onAction(String name, boolean keyPressed, float tpf) {

            if (name.equals("Pause") && !keyPressed) {

                setEnabled(!isEnabled());

            } else if (name.equals("Up")) {

                up = keyPressed;

            } else if (name.equals("Down")) {

                down = keyPressed;

            } else if (name.equals("Left")) {

                left = keyPressed;

            } else if (name.equals("Right")) {

                right = keyPressed;

            } else if (name.equals("Jump")) {

                playerControl.jump();

            }

        }

    };

    

    @Override

    public void cleanup() {

        rootNode.detachChild(localRootNode);

        

        super.cleanup();

    }

    

    @Override

    public void update(float tpf) {

        Vector3f camDir = camera.getDirection().clone();

        Vector3f camLeft = camera.getLeft().clone();

        camDir.y = 0;

        camLeft.y = 0;
        
        camDir.normalizeLocal();

        camLeft.normalizeLocal();

        playerWalkDirection.set(0, 0, 0);



        if (left) playerWalkDirection.addLocal(camLeft);

        if (right) playerWalkDirection.addLocal(camLeft.negate());

        if (up) playerWalkDirection.addLocal(camDir);

        if (down) playerWalkDirection.addLocal(camDir.negate());

        

        Geometry player = (Geometry) localRootNode.getChild("Player");
        
        if (player != null) {

            playerWalkDirection.multLocal(10).multLocal(tpf);
            
            playerControl.setWalkDirection(playerWalkDirection);

        }

        

    }

}

#5

#6

Ok thanks
Im a Code.
Ohh and it works on QWERTZ Keyboard too!


#7

This code is not helpful because it’s not where the problem is.

How are you building your application? SDK? Something else?

Where did you get your JME jars? Build them yourself? Download them from somewhere weird?

Does the basic game template run for you?

We need about 3465913746597346594365982456 more pieces of information than you’ve provided.

Edit: also, what version of Java are you trying to use?

Edit 2: basically, for some reason the JME jars in your dist folder are missing their versions.properties. This is where the exception happens:


How can I sign an application?
#9

In the SDK it works perfectly but not if you run the jar directly.
You’re clearly missing the classpath then. The proper “Deployment” is in the project settings selecting “Create Exe for Windows” or something and then build the project with the hammer icon.

Maybe someone else can help you with the command line but only doubleclicking the jar won’t pass the libraries from the libs folder in, so the game runs without the engine.


#10

Except then it wouldn’t even get as far as that exception.

The old SDK used to build a main jar with the relative classpath built into it. I don’t have the SDK installed so I can’t see what it puts in that dist folder.


#11

Oh that could be. But it would also fit the issue of missing ressources or JmeVersion.class being null.
Either way I’d try to launch the jar correctly as that seems to be where the problem lies


#12

Ok but where does the SDK put the libraries in?

?

#13

Hey it’s me again from another Account because I reached the maximum of answers for new users.

I tried to launch the JAR correct but I got the same error.
as first I tried to put the lib Folder into the JAR and Change something in the Manifest.MF

Then I tried to put everything in Eclipse (the libraries too) and as I wanted to run the Project I got the same error as before.

If you want to see my project here’s a Google Drive Link: https://drive.google.com/file/d/1dsEYGpU4xj8_MEXI02QCrwrFQx56Peah/view?usp=sharing Maybe you can see anything what I did wrong.


#14

i also have one suggestion:

create new basic game Project in JME IDE (change nothing in it), build it and launch the JAR from dist folder.

  • if work: then look at differences between projects.

  • if not work: then proceed with above posts suggestions.


#15

I created a new project, it worked fine as I started the JAR in the dist folder.

Then I changed out the lib folder and edited the MANIFEST.mf so that it runs my Main Class.

I got this:

C:\Users\emeld\Documents\Schinken\jMonkeyEngine_Workspace_oder_so\BasicGame\dist>java -jar MyGame.jar
Feb 10, 2019 1:16:59 PM com.jme3.system.JmeDesktopSystem initialize
INFORMATION: Running on jMonkeyEngine 3.1-stable
 * Branch: HEAD
 * Git Hash: af04bf9
 * Build Date: 2017-02-19
Feb 10, 2019 1:17:00 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFORMATION: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version: null
 * Scaling Factor: 1
Feb 10, 2019 1:17:00 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFORMATION: OpenGL Renderer Information
 * Vendor: Intel
 * Renderer: Intel(R) HD Graphics 630
 * OpenGL Version: 4.4.0 - Build 21.20.16.4565
 * GLSL Version: 4.40 - Build 21.20.16.4565
 * Profile: Compatibility
Feb 10, 2019 1:17:00 PM com.jme3.renderer.opengl.GLRenderer setMainFrameBufferSrgb
WARNUNG: Driver claims that default framebuffer is not sRGB capable. Enabling anyway.
Feb 10, 2019 1:17:00 PM com.jme3.asset.AssetConfig loadText
WARNUNG: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
Feb 10, 2019 1:17:00 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * 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
Feb 10, 2019 1:17:00 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNUNG: Pausing audio device not supported.
Feb 10, 2019 1:17:00 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio effect extension version: 1.0
Feb 10, 2019 1:17:00 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio max auxiliary sends: 4
Bullet-Native: Initializing java classes
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x1877de79, pid=7092, tid=0x0000475c
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) Client VM (25.201-b09 mixed mode windows-x86 )
# Problematic frame:
# C  [bulletjme.dll+0xade79]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\emeld\Documents\Schinken\jMonkeyEngine_Workspace_oder_so\BasicGame\dist\hs_err_pid7092.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
AL lib: (EE) alc_cleanup: 1 device not closed

#17

I created a new project, it worked fine as I started the JAR in the dist folder.

Then I changed out the lib folder and edited the MANIFEST.mf so that it runs my Main Class.
I got this:

see, its working, so your changes broke it.

can i know what you change in lib folder and MANIFEST.mf? was it mentioned in topic because i did not seen?


#18

I just replaced the lib folder from my real project with the lib folder from the new project. There is only one difference there : The assets.jar Then I copied the class packages into the new projects JAR and in the Manifest.mf I changed the Main class to de.EmeldemelTV.Hallospielewelt.Main


#19

you do it wrong way, i cant see what you do exactly, but you got JME IDE (modified netbeans)

and i belive you use Ant or Gradle build, i belive you use Ant.

so you need left click on project, go properties -> libraries, there are libs setting, you need to learn how to build libs with IDE.

see example:
asdasdasdasd

you see you got options on right there like add JAR, if you got external JARS you can add it here.

about JME libs you need click add library button

in this settings there also is setting somewhere for Main class run


#20

I don’t have any external JARS. The assets.jar is getting Auto gernerated while Building and the other libraries were pre-installed.

I tried to put assets.jar into the libraries but it still didn’t work.


#21

I tried to put assets.jar into the libraries but it still didn’t work.
Why? just dont do it. everything should work fine.

assets.jar are in libraries/path, its readed correctly by default, do nothing with it. Why you even want touch it or move? i dont get it.

open assets.jar with ZIP and see.

All you need to do is copy dist folder as runnable game.

about building dist folder, you need do it in IDE.

Ant got possibilities to change how it is builded.

as you see Assets.jar is correctly readable from this new project that you created. if you will put some new asset into project assets and use it, it will just work.

if you got assets generated in different project, then you need build this asset project and add project JAR (not assets)


#22

You said I have to put external JARs into the project.