This page is deprecated.

Newer, simpler instructions can be found on
a new page on netbeans and libgdx
click to dismiss

Summary

2012-08-23: newer page.

2011-04-03: I posted another article on how to use only Netbeans even for generating the package and for deployment.

It can be tedious to develop Android applications that uses OpenGL ES (like some games). The libgdx library makes it simpler. One of the features is that you can run your libgdx application not only on a phone (or emulator) but also on your desktop computer. The tutorials for libgdx are using mostly eclipse because of the first class android support with ADT (Android Development Tools).

This page is about creating a simple Netbeans project to develop your libgdx application. Because I'm lazy, I still use eclipse for deployment on the phone. Here, I will explain how to start from a tutorial from libgdx and work on it using Netbeans. As you will see, it's really straightforward.

Let's do it

Setup

I'm using the latest stable Netbeans (6.9.1) but it should work with any version. If you don't already have it, you need to install Netbeans (the “Java SE” version should be enough). Also, you need a libgdx tutorial, for instance the gdx-invaders-*-zip file from the download page of libgdx (in version 0.81 at the time of writting).

Make a directory, let's name it Heeere. Just unzip the gdx-invaders-*-zip file in Heeere. You should get the two gdx (eclipse) projects: one for the desktop and one for the deployment on android.

Now with Netbeans

Just open Netbeans and create a new project:

  • Choose “Java->Java App.” and click next
  • For the project name you can choose “gdx-invaders-netbeans” and use Heeere for the location
  • Uncheck the “use dedicated folder for storing libraries” box
  • Uncheck the “create Main class” box
  • Hit “finish”

Now we have to setup the project to reuse everything from the other (eclipse) project. Right click on your project and select “properties”:

  • In “Source Package Folders”, click “add folder” and choose the Heeere/gdx-invaders/src folder.
  • Still in this window, go to the “Libraries” category (on the left) and click “add JAR/folder”. Browse to Heeere/gdx-invaders/libs and select all the jars (with shift or control), select the “relative path” option and click “Ok”.
  • Still in the properties window, go to the “Run” category. In “Working Directory” put ../gdx-invaders and in “VM Options” put -Djava.library.path=libs and hit “Ok”.

That's it!

Now you can run your program, for example by hitting F6 and choosing the main class (only the first time).

libgdx with netbeans

I hope this was useful.
In case of problems, questions or remarks, just contact me at click-me ;-p @nospam.com.