public Material reloadMaterial(Material mat) {
        // clear the entire cache, there might be more clever things to do, like
        // clearing only the matdef, and the associated shaders.
        assetManager.clearCache();

        // creating a dummy mat with the mat def of the mat to reload
        // Force the reloading of the asset, otherwise the new shader code will not be applied.
        Material dummy = new Material(assetManager, mat.getMaterialDef().getAssetName());

        for (MatParam matParam : mat.getParams()) {
            dummy.setParam(matParam.getName(), matParam.getVarType(), matParam.getValue());
        }

        dummy.getAdditionalRenderState().set(mat.getAdditionalRenderState());

        // creating a dummy geom and assigning the dummy material to it
        Geometry dummyGeom = new Geometry("dummyGeom", new Box(1f, 1f, 1f));
        dummyGeom.setMaterial(dummy);

        try {
            // preloading the dummyGeom, this call will compile the shader again
            renderManager.preloadScene(dummyGeom);
        } catch (RendererException e) {
            // compilation error, the shader code will be output to the console
            // the following code will output the error
            Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, e.getMessage());
            return null;
        }

        Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.INFO, "Material successfully reloaded");
        return dummy;
    }
Will reload the spatial's materials whenever the shader file is changed
on the hard drive
@param shaderName the shader name (relative path to the asset folder or 
to a registered asset path)
@param spat the spatial to reload
jme3-core/src/main/java/com/jme3/util/MaterialDebugAppState.java