JME and IntelliJ

Hello,



I am trying to use intellij with jme3. I made a new project, add the jme3 libraries under File → Project Structure → libraries.



Then I created a new java.class

============================================================================



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 Game extends SimpleApplication {



    public static void main(String[] args){

    Game app = new Game();

    app.start(); // start the game

    }



    @Override

    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

    }

    }





    ============================================================================





    And run it. The little launcher starts, (Select display settings) but if i press okay i get the following error





    ============================================================================

    01.11.2012 14:34:54 com.jme3.system.JmeDesktopSystem initialize

    INFO: Running on jMonkeyEngine 3.0.0 RC2

    01.11.2012 14:34:54 com.jme3.system.Natives extractNativeLibs

    INFO: Extraction Directory: C:Usersuntitled

    Exception in thread “LWJGL Renderer Thread” java.lang.UnsatisfiedLinkError: Can’t load library: C:Usersuntitledlwjgl.dll

    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1706)

    at java.lang.Runtime.load0(Runtime.java:770)

    at java.lang.System.load(System.java:1003)

    at org.lwjgl.Sys$1.run(Sys.java:70)

    at java.security.AccessController.doPrivileged(Native Method)

    at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)

    at org.lwjgl.Sys.loadLibrary(Sys.java:95)

    at org.lwjgl.Sys.(Sys.java:112)

    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:206)

    at java.lang.Thread.run(Thread.java:662)

    ============================================================================



    It seems it can’t find the lwjgl.dll. Did I made something wrong?

You need to specify the local libraries… The LWJGL wiki has a guide on doing this in IntelliJ http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_IntelliJ_IDEA

Perhaps I speak too soon, but I just copied the ‘libs’ folder into a blank IntelliJ 12.04 project, added it as a library, and ran the above program. I did not need to set a JVM arg - the blue box rendered correctly and I could zoom the camera about. Some DLLs appeared at the root of my project as a consequence, but it all worked smoothly :slight_smile: I presume some extra JME magic has been added somewhere?

I also ran the HelloTerrain tutorial in IntelliJ without any VM tweaks…

The libs directory contains the natives as resources; copying them into the project made them available in the classpath, in the package that JME expects them in.
At runtime, JME copies the natives to a (configurable) directory and instructs the OS to load them from there. That’s why it doesn’t need commandline arguments.

You may want to just add the libs directory to the project classpath instead of copying it; that way, you don’t have to remember to copy the libs again if JME should update them (not that that’s going to be very likely anytime soon).
I have set up my JME project to have a “checkout” folder that contains an SVN checkout of http://jmonkeyengine.googlecode.com/svn/trunk/engine . I have instructed Eclipse to combine the classpath from those subdirectories that I actually need. I guess the same should be possible with IntelliJ.