/* jquery */ /* jquery accordion style*/ /* jquery init */
Showing posts with label Code With Java. Show all posts
Showing posts with label Code With Java. Show all posts

JavaFX Coding on Raspberry Pi

JavaFX on Raspberry Pi

In the July Java Magazine there's a tutorial-style article on JavaFX programming with the Raspberry Pi.

In this tutorial Frank Delporte explores a maker-style project and explains everything from first principles including Java installation, multiple code listings, GPIO introduction, the electronic components inventory list, circuit diagrams and much more.

If this article make you hungry for more Raspberry Pi Java and JavaFX coding material then check out Frank's book 'Getting Started with Java on the Raspberry Pi', which is available in both paper or ebook formats.

Inspirational Java Applications

Are you interested in taking your Java coding skills to a higher level?

Are you wondering what can be achieved using the Java language?

An recent article in the Free Java magazine lists 25 of the most significant Java projects over the last few decades.

Here's a little taste of some of these projects:

• The Maestro Mars Rover Controller
• Java Mission-planning and Analysis for Remote Sensing (JMARS)
• Wikipedia Search has a Java coded search engine
• Minecraft, the classic blocks-building game
• The Integrated Genome Browser visualisation tool
• VisibleTesla enables owners to monitor and control aspects of the Tesla Model S

Java 11 Coding on the Raspberry Pi

Java on Raspberry Pi

In the latest MagPi magazine issue #93 there's an article by Frank Delporte on the Java programming language.

The topic is Get Started with Java and Electronics and it's a great introduction to beginning to use the Java OpenJDK 11 - as included with the Raspberry Pi Raspbian operating system.

The article's code examples start with a 'Hello World' class, then move on to interfacing with the Raspberry Pi GPIO pins for developing electronics projects.

For the best Java coding experience you'll ideally need a Raspberry Pi 4 with as much memory as possible - 4GB would be best.

Java 14 Insights

A recent issue of Oracle's monthly Java Magazine highlights the latest edition of the Java programming language - namely version 14.

The magazine's articles highlight the essential functionality of Java 14 programming, including the new features and its Java Flight Recorder.

The Java Magazine can be read for free in HTML form. And each article is also available as a PDF download.

Read all my Java Coding posts

2017 Raspberry Pi Challenges

It's 2017 so why not set yourself some new year Raspberry Pi challenges. Here's a few ideas:

Start coding in Python with my free in-depth Learn Python on the Raspberry Pi series of posts.

Use Python code to explore the downloadable Astro Pi CSV data from Tim Peake's ISS mission and create a Python Date Filter.

Build your own Astro Pi computer using a Raspberry Pi 2 or 3 and a Sense HAT.

Learn the Java programming language with tools like BlueJ (maybe using the BlueJ Learning Videos), or the Greenfoot IDE or Dr Java.

Customise the hackable Raspberry Pi Minecraft edition using Python code or with Java using BlueJ.

More Raspberry Pi Coding, Tips and Tricks

Coding with Raspbian Jessie

Python

Right from the beginning Python has been the primary development language of the Raspberry Pi.

Install the latest Raspbian Jessie distribution image and you'll find both Python version 3 and the older version 2.7. Both versions come with plenty of source code examples.

Scratch

With Scratch, from MIT's innovative Media Lab, you can construct all kinds of multimedia projects without writing a single line of code. Scratch's highly visual interface is based around graphical, snap-together programming blocks and aimed at anyone old enough to use a keyboard and mouse.

On Jessie there's a built-in GPIO server, which simplifies GPIO pins access. Look at little closer and you'll discover this server also delivers direct access to the Pi's built-in camera interface and network IP addressing.

Parents and teachers might like to go to the ScratchEd online community where they can share stories, exchange resources and ask questions.

Java

With the Jessie image Java fans have two new applications in the main menu's Programming category.

Called BlueJ and Greenfoot they simplify the app building experience with a graphical coding environment that mixes mouse-driven design and code generation with traditional hand-coded statements.

C

Just like any other Linux-based operating system Raspbian's kernel code, device drivers, tools, utilities and graphical desktop are all written using the C language. However, learning a compiled language like C is a little more challenging.

The simplest way to begin is to play around with the pre-installed sample C programs. You'll find graphics, audio and video source code files, associated compilation 'make' files and a couple of helper C libraries in the directory /opt/vc/src/hello_pi.

Node-RED

Node-RED aims to deliver an easy-to-use development tool for Internet-of-Things (IoT) devices, including the Raspberry Pi. Created by IBM it's a browser-based tool built on top of Node.js, a popular free-to-install JavaScript server.

The user interface has a drag-and-drop flow editor, where you wire together combinations of blocks selected from a palette. Once constructed flows can be executed with a single click. Node-RED example flows include GPIO and camera interaction, web services, social media and Pi Minecraft communication.

Sonic Pi

With Sonic Pi you can compose your own unique musical compositions. It was created by Sam Aaron at the University of Cambridge, who hosts live, code-generated musical performances.

The Sonic Pi scripting language is designed around a set of simple, music-centric commands. The syntax will look familiar to those with experience of scripting languages like Python, although it's based on another popular programming language called Ruby.

Code Editors

There are a number of code editors pre-installed on Raspbian Jessie. Some are straightforward Linux text editor stalwarts like Vim and Nano.

Others, like Python's IDLE and the general purpose Geany, understand code syntax and so feature colour-coded listings, auto-completion, debugging support and general coding assistance. Geany supports many other languages including C, Java, HTML, XML and PHP.

More Raspberry Pi Coding, Tips and Tricks

Raspbian 'Jessie' and Java

As you may have already noticed on the Raspberry Pi blog there's a new major upgrade of the official Raspbian operating system, based on the Debian 'Jessie' release.

Amongst the many enhancements the 'Jessie' release now includes the Java-based BueJ and Greenfoot development environments by default.

So why not check out my Raspberry Pi Java section, which includes a number of BlueJ posts and a Greenfoot post.

More Raspberry Pi Coding, Tips and Tricks

More Raspberry Pi Java 8 and BlueJ 3.14

In the latest Oracle Java Magazine there's part 2 of Code Java on the Raspberry Pi by Michael Kolling which describes how to install, run and code with BlueJ version 3.14 on the Raspberry Pi.

And remember, this version of BlueJ includes the Pi4J library for direct access to the Raspberry Pi's hardware.

More Raspberry Pi Coding, Tips and Tricks

Java 8 and BlueJ 3.14 on a Raspberry Pi

In late 2013 Oracle released a Java language development kit (JDK) optimized for the Raspberry Pi's platform..

A short time later the Raspberry Pi Foundation included Oracle’s JDK by default in its Raspbian OS image.

However, running a coder-friendly Java editor, like the BlueJ IDE, on the Raspberry Pi was still a problem.

The good news it that in a recent Java Magazine article Michael Kolling describes how to install and run BlueJ version 3.14 on the Raspberry Pi.

Even better, this version of BlueJ also includes the Pi4J library for direct access to the Raspberry Pi's hardware.

Minecraft Pi Edition's main 'pi' package in BlueJ

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi JavaScript with Nashorn and Java 8

Would you like to write programs on your Raspberry Pi using the popular JavaScript language?

Well you can. Oracle's latest Java 8 release has a built-in JavaScript engine, known as Nashorn.

Here are a few of Nashorn's capabilities:
• run standalone JavaScript programs (no web server required)
• run JavaScript interactively from the command line
• access the complete Java library
• interoperate with existing Java code and APIs
• enjoy high runtime performance from the Rhino-based technology

That's a powerful feature set. For example, you could hack a Minecraft Pi Edition game in JavaScript by calling the functions defined in Mojang's Java API.

Oracle's technetwork site has an informative how to use Nashorn article. There's loads of code examples plus details of using the jjs command line tool, embedding JavaScript commands in Java programs and how to interact with JSON.

Benjamin Winterberg's blog post is another useful source in information.

The official Nashorn scripting reference documention is hosted on the Oracle docs website.

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi-Friendly Java Code Editors

Oracle's Java 8 has a number of new features to excite Raspberry Pi owners, as I mentioned in my Oracle Java 8 for Raspberry Pi post.

However, you'll still need a good code editor. Unfortunately some of the traditional Java IDEs (for example Eclipse and Netbeans) are large, memory-hogging applications.

In the posts below I describe a few Pi-friendly alternatives:

• Raspberry Pi Java with Geany
• Raspberry Pi Java with Dr Java
• Raspberry Pi Java with Greenfoot
• Raspberry Pi Java with BlueJ
• Raspberry Pi BlueJ Learning Videos
• Raspberry Pi Minecraft with BlueJ

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi Minecraft with BlueJ

Mojang created a special Raspberry Pi version of Minecraft specifically to encourage game hacking. This free version of the game includes Python and Java API's.

The API and Demo packages contain numerous classes. But what's a good tool for navigating the code?

Well, a visual way to begin Minecraft hacking in Java is with the BlueJ editor.

A recent Michael Kolling's Oracle Java Magazine article demonstrates how to install and run the Pi-friendly BlueJ 3.14 on your Raspberry Pi.

Open the API root source file folder as a Non-BlueJ Project. Now you'll have a class diagram for each package and a syntax-highlighting editor to browse the code. You can do the same for the Demo source code.

The images below give a flavour of how it will look.

The main 'pi' package:

The pi.event package:

The pi.demo package:

Source code for the LowLevelDemo class:

Javadoc for the Log class:

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi BlueJ Learning Videos

Are you just starting to code with the Java language and looking for a little help?

As I discussed previously the BlueJ editor is a great tool for beginners.

Recently I noticed object first with java, a comprehensive collection of videos which walk you through the basics of Java development with the BlueJ editor.

At the time of this post there's twelve in the collection.

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi Java with BlueJ

So the Raspberry Pi has a new performance-enhanced port of Oracle Java programming language.

But some of the traditional Java IDEs like Eclipse and Netbeans are large, memory-hogging applications. Is there a more Pi-friendly alternative?

The BlueJ Java programming environment aims to teach the fundamentals of object orientation (OO) design. While similar in concept to the closely related Greenfoot project BlueJ is targeted at students or anyone wishing to explore modern programming concepts through experimentation.

A graphical programming interface helps to visualise the high-level OO design, as opposed to just diving into the code. Behind the scenes there a full source code editor with built-in compiler, syntax-highlighting, scope-visualisation and auto-completion, plus an interactive testing mode.

It's an ideal solution when working with an unfamiliar set of Java classes, such as Mojang's Minecraft API for the Pi.

A recent Michael Kolling's Oracle Java Magazine article demonstrates how to install and run the Pi-friendly BlueJ 3.14 on your Raspberry Pi.

Alternatively, if your Pi is running the Raspbian image the BlueJ website has a Debian-specific .deb file download. After downloading move to the download directory, then execute this command in a terminal window:

$ dpkg -i bluej-314.deb

Below is a screenshot of BlueJ in action:

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi Java with Greenfoot

So the Raspberry Pi has a new performance-enhanced port of Oracle Java programming language.

But some of the traditional Java IDEs like Eclipse and Netbeans are large, memory-hogging applications. Is there a more Pi-friendly alternative?

The Greenfoot Java programming offers a highly visual way to teach the basics of object oriented (OO) design through simple user interactions. Aimed at coding beginners from around 11 upwards it's suitable for home-based or classroom learning scenarios.

With a graphical interface (see below) centred around user-defined actors that live in class-based worlds, Greenfoot offers an interactive and fun way to build games and simulations.

However, don't be fooled by the playful interface. All Greenfoot programs are built using standard Java. Behind the scenes there a full source code editor with built-in compiler, syntax-highlighting, scope-visualisation and auto-completion.

So the skills you'll acquire will be applicable to general Java development and other similar object oriented languages.

For Pi owners the pure-Java jar file version is the best option. Simply download the file, move to the download directory, then execute this command in a terminal window:

$ java -jar Greenfoot-generic-230.jar

You could create a desktop short cut which executes the above command for a more convenient single-click solution.

The Greenfoot website has plenty of helpful information and resources. Visit the documentation page to view the introductory tutorials, or take a look at the excellent collection of videos at the Joy of Code YouTube channel.

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi Java with DrJava

So the Raspberry Pi has a new performance-enhanced port of Oracle Java programming language.

But some of the traditional Java IDEs like Eclipse and Netbeans are large, memory-hogging applications. Is there a more Pi-friendly alternative?

Dr Java is one option. The classic interface has all the features you'd expect, such as syntax highlighting and one-click compilation or execution. There's a useful quickstart guide on the website.

For the Pi the pure-Java jar file version is the best option. Simply download the file, move to the download directory, then execute this command in a terminal window:

$ java -jar drjava-stable-20130901-r5756.jar

You could create a desktop short cut which executes the above command for a more convenient single-click solution (note: it can take a little while for the editor window to appear).

A screenshot of the Dr Java editor with a classic Hello World class appears below.

More Raspberry Pi Coding, Tips and Tricks

Raspberry Pi Java with Geany

The Geany editor is already a popular editor for Python programming.
But it has a Java side too.

Here's a few of the Java-friendly features:

• colourful syntax-highlighted Java source code
• visual Java class and function navigation
• easy code compilation via the 'Build' menu option or F8
• easy class execution via the 'Build' menu option or F5

Below is a screenshot of how the classic 'Hello World' class looks in Geany.

More Raspberry Pi Coding, Tips and Tricks