I keep getting an IllegalArgumentException when i try to load my textures, here is the code


package mygame;


import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.scene.shape.Sphere;

import com.jme3.texture.Texture;


  • test
  • @author normenhansen


    public class Main extends SimpleApplication {

    public static void main(String[] args) {

    Main app = new Main();




    public void simpleInitApp() {

    Sphere sph = new Sphere(20, 20, 4);

    Geometry geom2 = new Geometry("Sphere", sph);

    Material mat_sphere = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");

    mat_sphere.setTexture("GrassTexture", assetManager.loadTexture("Textures/GrassTexture.png"));





    public void simpleUpdate(float tpf) {

    //TODO: add update code



    public void simpleRender(RenderManager rm) {

    //TODO: add render code




    I dont get it, i placed the files in the assets/Textures/ directory and it is png and the name is right. But i have no idea what is wrong. Do spheres have to have something special?

There is no texture named “GrassTexture” in SimpleTextured.j3md… You sure you read the tutorial on materials?

I basically copied it from the material tutorial and its telling me, i changed “GrassTexture” to ColorMap and i still get an error, what can i put there that wont give me an illegalargumentexception?

dev1462 said:
I basically copied it from the material tutorial

Really? to what tutorial do you refer? I really doubt there is such a mistake in the tutorials, but if there is, could you point it out so we can fix it asap.

This can't work with the "GrassTexture" parameter, however it should work with "ColorMap".
Could you post the complete stack trace?

Check that this statement does not return null. (It would be a path problem, the file is not present or the case do not match the actual file name etc...)


if you call

mat_sphere.setTexture("ColorMap", null);

the engine tries to remove any texture previously bound to the ColorMap parameter, and if this texture does not exist throw an IllegalArgumentException.