LibGDX Tutorial – Part 2

Environment Setup

To get your code running you need to properly configure your development tools. And that’s one rough road. But once you setup your environment correctly, the successive projects will be easy to deploy. In this part, I will explain how to properly setup your development environment.

Here are the prerequisites for working with LibGDX:

  • Java Development Kit
  • Android SDK
  • IntelliJ IDEA (You can also use Eclipse or NetBeans but IntelliJ is the recommended IDE. Let’s face it, we have got to adapt to the changing development atmosphere. IntelliJ along with Gradle is the best way to go)
  • Setup environment variables of both Java and Android.
  • [OPTIONAL] Configuring Virtual Machine Acceleration for Android Emulator (Intel && Windows only).

Setting up JDK

Windows users

Download the latest Java SDK from here: and install it.

Ubuntu users

(I’m referring directly from this Ask Ubuntu post)

You can install JDK from the repository if you want the process simple. However, note that the repository is sometimes outdated and so may not always get important updates.

Using PPA

Open a terminal window and type the following commands one by one.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Or you can install Java manually.

Installing manually

Download the JDK tar.gz file from here:

Extract the compressed file:

Note: The Java version may be different for your system.

tar -xvf jdk-8-linux-i586.tar.gz
tar -xvf jdk-8-linux-x64.tar.gz

The files will be extracted to a folder named something like jdk1.8.0. Now we should move this extracted folder to /usr/lib

sudo mkdir -p /usr/lib/jvm
sudo mv ./jdk1.8.0 /usr/lib/jvm/

and after moving

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0/bin/javaws" 1

Note: The 1 at the end is for setting priority.

Now we should change the permission settings for the files just moved.

sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0


sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

If you have got this far without any errors, you have successfully installed Java on your machine. You can check the installed version using:

java -version

Setting up Environment Variable JAVA_HOME

Windows Users:

Find the Java installation path. The default path is something like C:Program FilesJava. Inside this, there will be a directory like Copy the path of this folder – C:Program


  • Open Control Panel
  • Select System and Security
  • Select System
  • Select Advanced System Settings
  • Select Environment Variables
  • Under System Variables, click New
  • Enter the variable name as JAVA_HOME
  • In the value field, paste the path you copied above.

Click OK and restart the system.

Ubuntu users:

The system variables are stored in the file /etc/environment. You should add JAVA_HOME variable to this file.

  • Open a terminal window and enter the following command:
nano /etc/environment
  • It will be opened in nano. Add this in a new line in the file:

Note: The Java version may be different for your system.

  • Write out and exit nano. Finally:
source /etc/environment

The variable is now set. Restart the system.

Setting up Android SDK

You can download the Android SDK from here:

Windows users

Download the executable setup file from the link above and install it. After the installation is complete, open the SDK Manager from the installed folder. Keeping the default options checked, install the mentioned packages. It will take a while to download and install the packages. Be patient.

Ubuntu users

As usual, it’s not that simple in Ubuntu.

  • First, download the SDK setup file for Linux from the link above.
  • Now, you should identify whether you have a 32-bit or 64-bit machine. Open a terminal window and type uname -a. It will tell you whether your system is i386 (32-bit) or x86_64 (64-bit).
  • If you’ve a 32-bit system, then go
sudo apt-get install libgl1-mesa-dev
  • Or if it’s 64-bit and if your Ubuntu version is 13.04 and below,
sudo apt-get install ia32-libs
  • If it’s 64-bit and Ubuntu 13.10 and above,
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
  • Extract the compressed file that you’ve downloaded from the link above to any folder – preferably at the home directory.
  • Run the file android in the tools folder. This is the SDK Manager.
  • Keeping the default options checked, install the mentioned packages. It will take a while to download and install the packages. Be patient.

Setting up Android environment variable

There’s no need to set up Android environment variable for Windows in common cases. If you want, you can copy and paste the path of the platform-tools folder in the Path.

Ubuntu users

Make the files in the android-sdk-linux folder executable:

sudo chmod -R 755 ~/android-sdk-linux

Edit the file .bashrc

nano ~/.bashrc

Add these lines at the top of this file:

#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

Write out and exit the editor.

Restart the system.

Install IntelliJ IDEA

Windows users

Download and install the application from here:

The Community Edition will be enough for our development.

Ubuntu users

  • Download the Community Edition tar.gz file from here:
  • Extract the compressed file to any directory, let’s say to home.
  • On a terminal window, cd to the directory ~/idea_extracted_folder/bin and enter the command:

This will start the application.

Virtual Machine Acceleration

Android emulators are notorious for their lag. You have to have a high powered system to get a fast emulator. Especially if you’re debugging games, that requires a good, fast emulator. A device might not always be in hand.

If you make use of the hardware acceleration option in the emulator configuration, even a decent system can draw the maximum speed. Here I’ll be explaining how to get a faster emulator in an Intel system by enabling Hardware Acceleration.

Note: The following step is applicable only in Windows with an Intel processor. If you’ve other systems, please google about acceleration in those particular systems.

First of all, make sure to enable Virtualization Technology in the BIOS settings. The methods are different for various motherboards. Please google how to boot into your BIOS settings and enable Virtualization Technology.

After enabling VT:

There you can see whether VT is successfully enabled in your system. If it is enabled, do the following:

  • Open the Android SDK Manager and install an x86 system image. ARM based images cannot be accelerated using this emulator configuration.
  • Make sure you have Android SDK Tools, Revision 17 or higher.
  • Install Intel x86 Emulator Accelerator (HAXM installer) in the Extras folder.
  • After downloading, open the IntelHAXM.exe file in /extras/intel/Hardware_Accelerated_Execution_Manager folder. Here you can configure how much memory should be allocated for virtualization. It’s recommended to keep the default values.
  • After installation completes, confirm that the virtualization driver is operating correctly by opening a command prompt window and running the command:
sc query intelhaxm

The result will be something like this:

SERVICE_NAME: intelhaxm ...

You have successfully enabled emulator hardware acceleration. Now when creating a new AVD, select the x86 image as the Target Device and enable Use Host GPU.

Yeah, this has been a loooong post but I believe I’ve covered almost everything you need to set up the tools required to start developing games using LibGDX. I’m not an expert, so you can mention any misinformation or doubts in the comments.

I’ll continue the tutorial series in upcoming posts.

Love Peace.


2 thoughts on “LibGDX Tutorial – Part 2

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s