Free Online Courses for Software Developers - MrBool
× Please, log in to give us a feedback. Click here to login
×

You must be logged to download. Click here to login

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

Raspberry PI: Mobile Platform for Java Development

This article shows how to install the operating system on the Raspberry PI and setup the Java mobile development environment

The Raspberry PI is a tiny microcomputer. Its main features include: small size, simple manipulation, powered by batteries that may last for hours, days, even weeks, and the plethora of available compatible hardware. These features makes the Raspberry a very promising platform for mobile development.

This article presents the Raspberry PI platform for those wishing to begin study it and have little or no knowledge about it. The article presents the OS installation on the device and the preparation for the Java development environment.

The Raspberry PI microcomputer is the first of its kind to sold millions of units in 2013, become worldwide popular, commercially available, and accessible to all. This mobile device was developed in 2006 at the Cambridge University, UK, by a team of computer science teachers and students in order to make easier the learning of programming languages and connect directly the end user with computer programming concepts.

The Raspberry is a small, cheap computer, manipulated more easily by children, teenagers, and learners in general. Besides the goal to motive learners, the Raspberry PI became an opportunity to families around the world have a cheap, mobile, programmable computer, with internet access, among other features that make it an innovative and truly personal computer. It was announced in 2011 and released in 2012.

The designers envisioned two models in the original design: a model A and B, which differed mainly by the following features: the number of USB ports (one for model A and two for model B), availability of Ethernet port (none for model A and one for model B), and price (approximately $25 for Model A and $35 for model Bin the United States). Nowadays only the B model is available for sale.

The Raspberry PI can be purchased through various web sites such as the Farnell store, which is one of the largest distributors of semiconductors and general electronic equipment with subsidiaries worldwide.

Another option is to shop it at Amazon.com. The value of Raspberry is affordable for most of the population, especially for students. Its usual price range isabout 80-130 US dollars.

Raspberry general applications

Since the Raspberry is a computer it can be used in almost any situation where a traditional computer could be. It has a Linux-based operating and it is possible, via the console, to create application servers, databases, and much more. However, an external hard drive (HD) maybe required to store a large set of files since the only storage device it has is a SD memory card, which is very expensive if you compare its cost per GB against a traditional hard drive.

The Raspberry OS also offers a graphical management system, which allows you to install and execute all kinds of cross-platform applicationssuch as word processing, spreadsheet, Internet Browsers, and others.

It is also possible to play multimedia data such as video, sound, and images. It can also run a few simple games.

However, once it has an ARM 700 MHz processor it may not wise to run CPU intensive applications like recent games and even software development environments such as Eclipse and Netbeans.

This article will show how to install the Netbeans IDE for developing a Java application from an education point of view. However, the reader should not compare the Netbeans execution’s performance with a traditional computer, since the Raspberry is known to be very slow for thistype of application.

Nevertheless, the size, simple operation, power supply provided by batteries that last for hours, days, and even weeks, and the myriad of available hardware that could be integrate to the Raspberry makes it a very promising mobile platform for development.

RaspberryPI’sphysicalfeatures

The Raspberry is a Broadcom-based chipset computer. It is slightly larger than a credit cardas shown in Figure 1.

TheRaspberry PI

Figure 1. TheRaspberry PI

The Table 1 shows the main hardware specifications of the device.

RASPBERRT PI TECHINICAL DETAIL - B MODEL
COMPONENT TYPE
SoC (System on Chip) Broadcom BCM2835
CPU ARM1176JZF-S, 700MHz, 32 bits
GPU Broadcom Videocore IV (OpenGL ES 2.0, Open VG, 1080p 30, H.264)
RAM 512 MB
USB 2 USB 2.0 ports
ETERNET 1 port (10/100 Mbps)
SD 1 slot
AUDIO 1 audio out (stereo)
VIDEO 1 VGA and 1 HDMI video ouput

Table 1. Raspberry PI hardware specification.

The Raspberry PI does not have a display for presenting basic information to the user, such as if it is powered on or off. This "data output" is shown through five LEDs on top of the device. Table 2 shows the meaning of each of LED.

LEDs STATUS AND MESSAGES DESCRIPTION
LED COLOR MESSAGE DESCRIPTION
ACT Green The SD card is being used
PWR Red The RPi is powered by to a 3.3V power supply
FDX Green Lights up if the Ethernet connection is full-duplex
LNK Green Lights up when there is network traffic
100 Yellow Lights up when connected to a 100 Mbps network

Table 2. Raspberry PI LED status and message description.

Note: Raspberry PI board

After the purchase of a Raspberry PI it comes without peripherals or cables, just the board. Therefore, the reader should be aware to purchase the accessories. To power on a Raspberry the reader must also purchase a power source. It is useful to have a USB cable to transfer programs/files from a traditional computer, a compatible monitor with HDMI, and a USB keyboard and mouse.

Peripherals

The Raspberry PIneeds a power source (battery or external). The source may be the USB port of a traditional PC. In this scenario the Raspberry is powered bythe USB cable.

However, as a general recommendation use the USB cable only to transfer data and not to power up the Raspberry. This recommendation is based on the fact that many USB device ports probably will not provide the minimum electrical current to the proper operation of the board.

For instance, the USB ports of computers hardly exceed the 400 mA electric current, therefore the Raspberry PI does perform as expected and may not boot up or freeze during its use. Thus, the general recommendation is to acquire an external power supply that provides at least 5V and 700mA.

To connect Raspberry into an external display the reader must pay attention to the input display signal as the Raspberry only has a HDMI output, which is not very common on most monitors and multimedia projectors. Due to this fact, it is advisable to purchase a HDMI to VGA converter, which will send data even for older displays.

It is also important to connect a mouse if the readeris going to use the graphical environment of the Raspberry PI and a USB QWERTY keyboard.

However, it is often impractical to use traditional keyboards and mice, since both occupy the only two USBs ports. As an alternative, there are tiny wireless keyboard/mouse products that facilitate the connection with such small like the Raspberry Pi.

Finally, a storage device (such as an external HD) style is needed to store the operating system, applications, and files. Some companies sell SD cards with the Raspberry Pi operating system ready in such a way that the user just has to insert the card and power on the device to be ready to work with the Raspberry Pi.

However, the cost of an external HD may be prohibitive and a more feasible solution is to purchase a traditional SD card with at least 4GB of memory found of class 4 card types capable of transferring at least 4MB/sec.

Besides the peripheral already mentioned, there are others available such as a LCD display for displaying data, a LED matrix, some boards for electronic drive (PIFaces), and even acrylic boxes to safely store the Raspberry PI.

Setting up the SD card on Windows 7+

When the mentioned items connected to Raspberry PI board the device is ready for use. However, an Operating System is required to manage all the Raspberry PI features.

The most widely used operating system for the RPi is called Raspbian. It is a special version of the Debian O.S. that has been optimized for the Raspberry PI hardware. The device also supports other Linux-based systems such as GNU/Linux, Fedora, Arch Linux ARM, and RISC OS.

The OS can be downloaded or purchased and it must be stored on the SD card. The reader should insert the SD card that contains the image of the Operating System in the slot, connect the power cable to the power source and then turn the device on. This article will show a step by step procedure to install the Raspbian operating system on a SD card to help the novice users of this device.

The download of the Operating Systems that can be used with the Raspberry PI is found on Downloads tab of the device’s official website (see Links section). In this site there are also forums, help pages and general information about the small computer, its creation and development.

Among available downloads there are the image filesfor each individual Operating System supported, including the Raspbian. The file that this article recommends is called NOOBS (New Out Of The Box Software), which contains all the required files to boot the Raspberry PI.

A very important detail: the reader should check the version of noobs that will be downloaded and make sure there is enough available space of the SD being used on the Raspberry PI.

This article uses the NOOBS 1.2.1 version, which can also be found at various locations on the Internet. As a suggestion, download the download NOOBS_v1_2_1.zip file available at the Raspberry site, since it can be stored on a 4GB or bigger card.

The official Raspberry PI website of has the latest available version. The reader can always opt for the latest version; however check the card to see if it supports the installation files, as already mentioned. Regardless of the chosen version, the procedure is exactly the same and will be explained bellow.

After getting the file NOOBS 1.2.1 the reader you must use a program that wipe out all the data from a device. The application that performs this erase is called SD Formatter for Windows and it is freely available for download at https://www.sdcard.org/downloads/formatter_4/eula_windows/.

It is useful to use the CheckSum calculator code to verify the integrity of transmitted data and make sure that the file has not suffered any data loss or transmission error. The reader can download the executable sha1sum.exe at the following address: https://code.google.com/p/toolkits/.

After the download of the applications, the setup of the Raspberry Pi and the Raspian OS installed on the 4GB SD card the system is ready to boot up. The SD card must be inserted into the card reader slot of the Windows computer. Then, the program SDFormatter must run and show the interface presented in Figure 2.

Main interface of the SDFormatter program

Figure 2. Main interface of the SDFormatter program.

The device that allows access to the card,should be recognized by the computer and the SD Formatter Using the Drive option choose the volume in which card was found. Press the Option button to select the QUICK option for the Format Type and the ON option for the Format Size Adjustment as shown in Figure 3.

The Option Settings window of the SDFormatter tool.

Figure 3. The Option Settings window of the SDFormatter tool.

To return to the previous interface click the Format button and a message will inform that the formatting process was successful. After this step create a new folder and place the NOOBS_v1_2_1.zip and sha1sum.exe files inside it.

Before writing the file on the SD card use the CheckSumprogram to check it the download OS file is valid. The interface CheckSumprogram is shown in Figure 4.

The sha1sum interface

Figure 4. The sha1sum interface.

On the sha1sum interface press the Select File button, choose the file to be submitted to CheckSum, which in this case is the NOOBS 1.2.1.zip found in the same folder. When the file is selected the program immediately starts the calculation and the result is displayed in the key field sha1sum.For the NOOBS 1.2.1.zip the correct key is:

BDB61930B077DCEFD22B36CAAA9698BDF76B290D

If the result isnot matching, it is likely that the file iscorrupted for some reason. Thus, the recommended approach is to download itagain andperform the calculationto ensureit will workuntil you getthe correct key.

Each version of the NOOBS has a different CheckSum key. For instance, the NOOBS version 1.3.7 has the following key:

A0042AEECFDA080A965DA8E2706CD28A17A1C346.

The next step is to extract the compressed files from the NOOBS 1.2.1.zip on the root folder of the SD card volume. Figure 5 shows the items that should be on the SD card after this process.

Installation files

Figure 5. Installation files

After the file’s extraction the card can be ejected and placed inside the SD Card slot on the Raspberry PI, which can be connected to the voltage source and powered up.

Turning the Raspberry PI on with the already inserted SD card will show a window, similar to Figure 6, which displays the boot options for the OS installation process.

Initialization window of the Operating System installation process

Figure 6. Initialization window of the Operating System installation process

The Raspbian [RECOMMENDED] option should be selected and then the Install OS button can be pressed. After those actions the Raspian Operating System will begin its installation. A window will appear indicating the success of the operation at the end of the Raspian OS installation.

The implementation will ask for a username and password after installation of the environment. It is recommended to use the default values for those values, which are:

  • raspberrypi login: pi
  • Password: raspberry

After these steps the user is ready to use the Raspberry Pi console without the visual environment. The following command must be entered in the console to start the visual environment:

pi@raspberrypi ~ 
array2
nbsp;startx

RaspberryPi settings

The first time that the Raspberry PI is started it shows the raspi-config, which is the toolwhere some important settingsmust be set ​​before starting the graphical mode. If some setting must be changed later on the reader must return to that configuration tool by typing the following at the command line:

sudoraspi-config

The arrows keys up and down are used to configure the options in this tool. They move the cursor up and down in list. The Space key is used to select an option and the tab key change the fields or to move the cursor to the buttons at the bottom of the window, as shows in Figure 7.

The menu of the raspi-config tool.

Figure 7. The menu of the raspi-config tool.

The first change to be made is change the default password Raspbian, which by default is raspberry. This change is made through the Change User Password option. When this option is chosen a line is presented in the lower left corner of the screen in which the user can type the new password. After the user enters the new password a screen will appear informing that the password was changed successfully.

The next option is the configuration of the location through the Internationalization Options. The choice of location will also affect the keyboard configuration, which by default is a generic keyboard with UK layout.

By completing these settings is now possible to start the Raspbian in graphical mode (Figure 8).

The RaspbianOS in graphical mode.

Figure 8. The RaspbianOS in graphical mode.

Installing the Java development environment

The Raspberry developer’s team always wanted a product that would facilitate both the learning of programming languages ​​as their use in various applications, since the mini-computer has features for many applications despite its size.

Since there are many possible applications, the support for the Java language was soon arranged.This helps making the Raspberry PI a potential new platform for programming.

Some Oracle features must be installed to develop applications using the Java language with Raspberry PI. These features can be installed through commands on the Raspbian terminal after the network interface is configured to allow internet access.

The Raspbian terminal that allows shell commands is called LXTerminal. It ca be executed by clicking on the Desktop menu in the lower left corner of the screen, accessories tab, and then on the LXTerminal icon.

sudo apt-get update &&sudo apt-get install oracle-java7-jdk

The integrated developmentenvironments (IDE) can be installed after the complete installation of these resources, which can take several minutes. The reader has many options such as Netbeans or Gedit that also can be installed from the command line. For Netbeans, just give the terminal the following command:

sudo apt-get install netbeans

And for the Gedit:

sudoapt-getinstallgedit

Once the download is completed each of these programs can be run normally bynavigating among theRaspbian installed programs or with a doubleclick on the icons created on the desktop.

The NetbeansIDE can be used in several Java applications, however it may be slow compared to Gedit or other editorsdue to the Raspberry PI’s architecture.

The preference for interface development is a choice of the programmer, but the reader must remember that Netbeans is a great and very easy tool for those who are new to Java programming, in particular when the programmer needs to debug the code.

In this article we choose the NetBeans IDE version 7.0.1. Using this version a new project can be created through the File menu that has the New Project option. These step lead to the screen displayed in Figure 9.

Starting a new project on theNetBeans IDE

Figure 9. Starting a new project on theNetBeans IDE.

If the reader chose the Java and Java Application options the new project’s details (such as its name) can be edited, as Figure 10 displays.

Settings for the new project.

Figure 10. Settings for the new project.

In this example the new Project was named "Hello World" and the settings file location and package name in which it is stored as patterns were maintained. By clicking the Finish button the project is created and ready to receive the Java code.

Listing 1. HelloWorld.java - A first Java application on the Raspberry platform.
public class HelloWorld {   

public static void main( String args[] ) {   
System.out.println( "*** Hello World ***" );   
System.out.println( "We can develop Javaapplication with Raspberry PI!" );   
}   
}

The following messages are displayed in the IDE console after the program is run: "*** *** HELLO WORLD" and "We can develop Java applications with Raspberry PI!". Those messages can be seen in Output window. When the program is run via console the messages can be seen on the device screen.

Conclusion:

Although this article presents a simple application, it opens the door for the developer who wants to start with Raspberry and perhaps go to more advanced features of the platform such as AWT and SWING GUIs, file handing,socket manipulations, parallel programming with threads, and more.

With the simple steps presented in this article and prior knowledge of the Java platform the reader can imagine the many applications. The platform’s main advantage is its mobility, small size and processing power that together surpass the other existing microcontrollers found on the market.



Microsoft MVP, Bachelor in Science And Technology, Editor and Consultant at DevMedia with more than 7 years of experience in software development.

What did you think of this post?
Services
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits
[Close]
You must be logged to download.

Click here to login