but what... is it good for?

Setup (1/2): JDK, Android SDK, Eclipse

What we're about to do:

Because the scope of this post grew a little bit larger than I expected, I divided it into two parts. This article will cover the installation process of the Java Development Kit, setting up the path variables in Windows and installing and setting up the right version of Eclipse. If you already have a JAVA SDK installed, you are free to skip this part. At least, a Java 7 needs to be present. Java 6 is not supported for our purposes. 

Today we discuss the matter of installing a Java respectively Android development environment. We prepare everything to run and debug LibGDX Code on your computer. It is necessary to meet some software requirements.

I will explain the required steps and settings for a windows system with the IDE Eclipse. Of course, everything discussed applies in slightely modified form to Mac OSX and Linux too. A very good alternative for eclipse is the IntelliJ IDEA from jetbrains, especially in the form of the Android Studio. I for one prefer the Eclipse IDE.

Lets take a moment to talk about Java first:

Java is a widely platform independent, object oriented programming language. But what does this mean in this context?

Opposed to other languages like C or C++ (compiler languages), the human readable code is not translated into maschine code (compiled). Maschine code means food, only the processor is able to eat. The program logic and algorithms is broken up into atomar pieces, which can be processed by the processor. Since different processors uses slightly differen commands, our atomar pieces of code are not digestable for every processor. So, for every other platform the source code needs to be compiled in a for this processor digestable set of commands. So this is how compiler languages work. On the other hand, there are interpreter languages like java script or PHP. This means, the human readable source code is (mostly) not going to be optimised and gets interpreted directly at runtime. On the downside, this methodology is significantly slower than for the processor optimized instructions and commands in maschine code.

Java represents some sort of hybrid between interpreter and compiler languages. Though the source code is getting compiled, the outcome of this compiling is no maschine code, ready to be fed directly to a processor. Instead the compiler spits out something called bytecode. This bytecode is way better optimized than the human readable source code and thus is executed in less time. Since it is not directly fed to the processor, this bytecode can run on any machine, no matter what architecture and operating system. The twist in this is, on the target device has to be a maschine running, able to interpret the bytecode, translate it to maschine code and feed it to the processor. This maschine is called the 'java virtual machine' (JVM). The JVM is part of the java runtime environment (JRE), which needs to be installed whereever a computer wants to run a java program. So this is the reason, java bytecode can run on every system and is platform independent. Because there is a JVM, taking your bytecode and translating it for the processor.

In times past, there was a disadvantage in this procedure. The interpreatation from the bytecode to maschine code was still slower than a readily compiled executable. Through steady improvement of the just-in-time compiler (JIT) it was possible to strongly increase the speed. Now, Java stands tall and is almost as fast as a pre compiled executable.

Enough chit chat. Lets do this:

Only thing you need to download from the oracle website ist the Java SE Development Kit 8 (JDK). Another important notice: I, obviously, do not take the blame if for whatever reason you computer is ruined after you followed this tutorial. You do this at your own risk. But, no risk, no fun. :) And it's not that big of a risk anywhay. After successful installation process, you should set the path environment variable, so that the compiler knows where your newly installed sdk resides and you can use it from the shell. If the install routines have already registered the bin folder from the sdk in the path variable, the following steps are not necessary.Falls noch nicht vorhanden, geht ihr so vor:

  1. Open the system info panel (windows key + pause)
  2. Click on the Advanced System Settings Link in the sidebar
  3. Change to the tab Advanced and click the "Environment Variables" button near the lower bottom of that tab
  4. Add a new system variable with the name 'Java_Home' (if it isn't already there). The value should be the path to your java sdk installation.
  5. Open the path environment variable and add ";%Java_Home%\bin" at the end (without the quotation marks). !!Take care: Do not change anything else within the path variable!!
  6. Almost done. Reboot your machine and test if everything is set up properly. Therefor, open a command shell and type 'javac -version'. Now you should see the version of the java compiler you installed previously. If you see an error message or something else, you are probably doomed and beyond help. Don't panic. Just go for another profession. Computer Science is not for everybody.

Eclipse:

Next, you need to download the latest version of the Eclipse IDE. It is a very flexible and useful development environment, used for many different languages. The latest release is called Luna. Eclipse arose from Java, though. It is not only an IDE, but a framework to generate various other development tools. But we probably won't face this part of eclipse ever and use it primarily as Java IDE. For this reason, the download package "ECLIPSE IDE for Java Developers" is sufficient for our purposes. Unzip the archive to your applications directory and shortcut the Exlipse.exe to your desktop.

After you've started Eclipse, you ought to specify a workspace directory. Do not worry, it is not the directory where yor projects resides on your hard drive.

Workspaces are used in Eclipse to group related projects together and have them simultaneously available within the IDE. This is the reason we are, for example, able to keep all the tutorial projects open at the same time within Eclipse and don't need to worry about finding and opening them. The directory, which represents the workspace, is only used to store meta data about the projects in this workspace. You can organize your real project folders and files on your hdd as you desire. In Eclipse, you need to import these projects with the Import-Tool in your workspace. After this, they are prepared to start developing or debugging on them. After opening a new workspace, the welcome tab is shown. Simply click on "Workspace" in the right upper corner and you are good to go.

Android SDK:

To utilize the classes, methods and functions from the Android syste, you need to install the Android SDK on your system. Make sure to download and install the stand alone sdk tools and not the Android Studio. After the install process, you need to start the SDK-Manager application (!!IMPORTANT: as admin!!). Choose the desired packages and install them.

Depending on which items you chose, this can take a little while. To develop with libGDX, you ought to install API level 8 at least. But I recommend to go with the 'latest and greatest'. Some interesting items are hidden in the 'Extras' section, like Google USB driver (you need them if you want to debug with nexus devices).

After all SDK packages are installed, you need to set the envirionment variable for the android sdk too. If the install routine has done this already, the following steps are not necessary for you. Just check, if the PATH variable has it's way to find the android tools. If not, you do it this way:

  1. Open the system info panel (windows key + pause)
  2. Press the "Advanced System Settings" link in the sidebar
  3. Change to the tab Advanced and click the "Environment Variables" button near the lower bottom of that tab
  4. Add a new system variable with the name 'Android_Home'. The value should be the path to your android sdk installation.
  5. Open the path environment variable and add ";%Android_Home%\tools;%Android_Home%\platform-tools" at the end (without the quotation marks). !!Take care: Do not change anything else within the path variable!!

Now, reboot your machine. You're almost done with part 1 of this tutorial.

Eclipse ADT Plugin:

We just need to learn eclipse to utilize this new android sdk, to recognize logs from android devices and to enable android debugging. Thus, we need to install the ADT plugin. ADT = android development tools.

  1. Click help within eclipse. In the menu, click 'install new software'
  2. Press the 'add' button to add the following new update location for the adt plugin:
    Location: https://dl-ssl.google.com/android/eclipse/

  3. Select the new location in the "work with" dropdown.
  4. check the developer tools and press install

 

Jetzt müssen wir die Installation nur noch testen:

  1. Startet Eclipse
  2. File -> New -> Java Project
  3. Hallo Welt aufklappen und mit der rechten Maustaste auf src klicken
  4. Im Kontextmenü New -> Class auswählen
  5. Folgenden Source-Code in die neue Klasse schreiben:
    package myFirstPackage;
    
    public class HalloWelt {
    	public static void main(String[] args) {
    		System.out.println("Hello World!");
    	}
    }

     

  6. Rechte Maustaste auf die neue Klasse
  7. Im Kontextmenü Run As -> Java Application auswählen
  8. Im Console-Tab sollte die Ausgabe "Hallo Welt" erscheinen.

Congratulation. You now have your system prepared to develop Java and Android.
In the next unit, we will cover dependency management with gradle, the setup and import process from a new libGDX project and the execution and debugging of your first hello world application.

Last modified onWednesday, 31 May 2017 15:37
Michael Wagner

...is a web- and gamedeveloper currently employed by Microtronics Engineering Limited, where he works on M2M software and the internet of things. He also teaches webdevelopment at the university of applied sciences St. Pölten. In his spare time he usually works on new videogame ideas, tinkers with various webdev toolchains, does some sports, makes music or is hitting the fields with his cam. On top of that, he is busy with his master course "Web and Mobile Media Design" at the Danube University Krems.

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
FaLang translation system by Faboba