(Re)Building does not reflect code changes

I’m new to Java and jMonkeyEngine, coming from C++, and this strange issue has started coming up. I can’t for the life of me figure out what seems to be the problem. I’ve seen it crop up doing some basic java stuff earlier, and now again with the jMonkeyEngine SDK. I’ve even tried switching to my Windows machine to see if that made any difference, but it doesn’t.

For this I’m using the ‘HelloSimpleApplication’ demo from the offline tutorial, provided with the jMonkeyEngine 3 SDK.

When I compile the project for the first time, after following all the steps in the tutorial, the program works fine. I can see the blue cube and move around it. All seems good. When I change anything about the program and rebuild, the program that’s run does not reflect the changes I made.

If I change the cube’s material to be Red instead of Blue by changing ‘mat.setColor(“Color”, ColorRGBA.Blue);’, I build the project (with or without clean) run it, and the cube is Blue.

If I deliberately introduce typos to the program, such as changing ‘app.start();’ to ‘app.stxxxxxxart();’ the building process gives me an error. When I choose ‘Run Anyway’ the program works perfectly, as it did before.

This is on a clean installation of the SDK (with IDE) that’s been updated until no new versions were available.

My sanity’s at stake here! I really hope someone can help provide some insight into this maddening issue.

It should “just work” so I understand your frustration :slight_smile:

Check if “compile on save” is activated. If not you’d need to explicitily invoke clean & build (which I see you’ve done but still).

You can try to clear the SDK (netbeans) cache as described here http://hub.jmonkeyengine.org/groups/general-2/forum/topic/nonsensical-runtime-exception

It might just be a case of temporary insanity in the SDK cache that thinks it has compiled the file even though it has been changed later.

check your psvm (public static void main) function. Are you sure your referencing the right class in it?

@rider said:
If I deliberately introduce typos to the program, such as changing 'app.start();' to 'app.stxxxxxxart();' the building process gives me an error. When I choose 'Run Anyway' the program works perfectly, as it did before.

"Run Anyway" will simply run the latest successfully compilation. Typos will cause a failure to compile, so you would expect to see the same result after introducing typos. I would recommend running a debug and set a mark where you set the material color to see if the line is actually executed.

Thank you for the quick reply!

Turning off ‘Compile on Save’ and clearing the cache has definitely helped some! I can no longer make any syntax mistakes, the program won’t build/run anymore, which is fantastic!

Unfortunately, I’m not out of the woods yet. It seems that now, as long as the compiler doesn’t throw any errors of any kind, I still end up with the same program. Changing the Cube’s color still does not work. If I change any of the values in quotes (the Box in ‘new Geometry(“Box”, b);’ or the material path in ‘new Material(assetManager, Common/MatDefs/Misc/Unshaded.j3md");’ ) to any other value the program behaves the same as it would’ve previously.

For reference, this is the program I’m working with:

[java]package jme3test.helloworld;

import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.math.ColorRGBA;

/** Sample 1 - how to get started with the most simple JME 3 application.

  • Display a blue 3D cube and view from all sides by
  • moving the mouse and pressing the WASD keys. */

    public class HelloJME3 extends SimpleApplication {

    public static void main(String[] args){

    HelloJME3 app = new HelloJME3();

    app.start(); // start the game



    public void simpleInitApp() {

    Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin

    Geometry geom = new Geometry(“Box”, b); // create cube geometry from the shape

    Material mat = new Material(assetManager,

    “Common/MatDefs/Misc/Unshaded.j3md”); // create a simple material

    mat.setColor(“Color”, ColorRGBA.Blue); // set color of material to blue

    geom.setMaterial(mat); // set the cube’s material

    rootNode.attachChild(geom); // make the cube appear in the scene



Ladies and Gentlemen, I have found the issue!

It appears that, when you create a new project off of the JME3->Basic Game template, you already get an initial package (mygame) with a Main.java file. This file contains the sample as it’s described in the first tutorial. The tutorial however tells you to create a new package first! This means that, although it LOOKS like you’re actually making that happen, you’re in fact building an existing source file, so naturally any changes you make to this new package won’t reflect in the application run.

In short, the tutorial does not align with the reality of what happens when you follow it to the letter!

Thanks for all the help anyway :smiley:

I guess it depends on how you are getting the tutorial running etc (for example all the tutorials are bundled in the sdk, just do new->jme3 tests to see them).

To be sure what you are running you can either check the project settings…or if you right click a .java file with a main() in it you can tell the SDK to run that specific file rather than the main project one.