Friday Mar 22, 2013

Introducing Kids to Java Programming Using Minecraft

Minecraft is a wildly popular game among elementary and middle schoolers. The game allows players to build constructions of textured cubes in a 3D world.

My son has been playing the game for about a year, lets say addicted to it. Last Fall he told me that the game is corrupted because the JAR file snapshot has messed up the configuration. And that right away rang a bell in me as a Java Evangelist at Oracle.

I learned from him that the game is written in Java, has a trial version that runs as an applet in the browser, and downloaded as a JAR file for desktop. The game is modular where the players travel through a world and chunks are loaded and unloaded to keep the memory footprint small. Something unique about the game is the ability to modify the game from what it was originally designed for. In Minecraft language, this is called as a "mod" - short for modifications. For example, a mod can add new characters to the game, change look-and-feel of the play field, or make it easy to build new structures.

The game has a server and a client component. This allows the game to be played in a single player mode where a player connects to a server using a client and plays the game. Alternatively multiple players, using different clients across platforms, can connect to a server and play with each other collaboratively. Its very common to have a server run with multiple mods. There are almost an infinite number of mods someone could do to make Minecraft a more amusing game to play. There is no official API to create these mods but there are several third-party vendors that provide that capability; Bukkit is one such API. The ability to write mods and alter the game play gives players more control over the game and gets them more excited.

My son expressed his desire to write a mod and so we started exploring further. Then onwards, he started teaching me Minecraft vocabulary and I taught him the Java programming concepts. Our discussions in the car, on the dinner table, during the breakfast preparation, and elsewhere changed to reflect that as well. He already played with Scratch and Greenfoot last Summer and that was extremely helpful during this learning curve. We set up a goal to build a mod during Christmas break. After understanding the basic concepts and building a few mods, we decided to share the knowledge with a broader set of Minecrafters. And that's where the concept of doing a Minecraft Workshop was born.

My son came up with a list of his minecraft buddies and we announced a date for the workshop. Everybody invited for the workshop confirmed their presence right away. I found out that both the invited kids and their parents were equally excited. One friend could not attend because of a prior commitment and was extremely disappointed. On the day of the workshop, some kids were eager to come even before the formal start of the workshop.

The workshop was attended by 10 kids with age ranging from 10-14 years. Most of the kids had no programming experience, let alone Java. However there was high Minecraft experience in the group with some kids playing for about 2 years and up to 2 hours every day. When given the topic of Minecraft, the small group would talk excitedly about different aspects of the game, constantly using hundreds of game-specific terms and phrases as if speaking a different language. My goal was to leverage their passion and introduce them to Java programming.

The challenge for me was to introduce programming to these kids using analogies from the daily life. Using a car, features, capabilities, types, and car dealers and correlating with class, properties, methods, instances, and packages seem to work. Fruits and different methods of peeling, eating, and planting was used to introduce the concept of Interface in Java. I asked, “What can you do with a watermelon?” the first answer was obvious, “you can eat it.” The second one was a little less so, “You can chuck in a trash can.” The response was greeted with scattered laughter. I used that to explain the concept of Exceptions in Java.

Short anecdotes and side-conversations kept the livelihood of the group going throughout the five hour programming session. There are almost an infinite number of mods someone could do to make Minecraft a more amusing game to play. But all these mods hold the same basic framework that we set up for any future work on making game-specific mods. By the end of the session, we had worked out an entire framework for making a mod. A Maven archetype to create a template Bukkit plugin allowed the attendees to avoid writing boilerplate code. A lower bar to get started and simplicity was the key for this audience. The mod built in the workshop added a new server-side command and printed a trivial message.

Although the goal of the workshop was to get an introduction on programming and make a Minecraft mod, I believe the attendees learned much more than that. I think the informal set up helped them discover that programming can be fun and useful to add to gaming experience. Programming is a vast field and we barely scratched the surface. But most importantly, the attendees had a good time and learned their first lesson of Java programming to start off an interest in it.

"Fun", "Easy", "Quick", "Awesome", "Short", and "Intuitive" described attendees' one word summary of building and running their first Hello World application using NetBeans.

All the instructions followed in the workshop, including a lot more pictures, are available at

For me, it was quite a humbling and learning experience. I've delivered multiple workshops all around the world but mostly to professional developers. I realized how the instructions need to be completely spelled out in order for the attendees of this age to make progress. Something as simple as "Hit Enter after entering the command", yes, that is required. Anyway I plan this to be the first of many more workshops aimed to introduce the world of Java programming to school students.

One of the lessons learned during the workshop was to simplify the installation experience. All the kids had JDK and NetBeans set up already, pretty straight forward. However I wonder why Maven insists on JAVA_HOME variable instead of figuring it out. I need to investigate how to seamlessly install JDK, NetBeans, and Maven in a platform independent way. This will allow to focus more on building the actual mod rather than the multi-step installations.

This workshop was not possible without mentoring support from Allen Dutra and other parents. A huge shout out to my family who helped validate and calibrate my strategy for the audience. My nephews feedback from the lab is incorporated into this blog. Thanks to Oracle for sponsoring the snacks!

Thank you @notch for using Java to build the game! You've provided a great platform for young kids to learn Java and truly enabled Make The Future Java ...

Sunday Feb 03, 2008

How NetBeans helped in 100th day of school celebration ?

My friend's daughter got a family assignment from school to commemorate 100th day in school. If each letter in the English alphabet is assigned a weight corresponding to it's position (e.g. "a" is 1, "b" is 2, ... "z" is 26) then she was supposed to collect 10 words whose letters sum total to 100.

They spent last 1.5 days and found only 3 words and were discussing the problem at the lunch table earlier today. Here is a small piece of code that I wrote to help them out:

import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static final char[] WEIGHT = {
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
        'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
        'w', 'x', 'y', 'z'

    \* @param args the command line arguments
    public static void main(String[] args) throws Exception {
        if (args.length == 0) {
            System.out.println("At least one argument required");
        BufferedReader in = new BufferedReader(new FileReader(args[0]));
        String string = in.readLine();
        while (string != null) {
            StringTokenizer tokenizer = new StringTokenizer(string);
            while (tokenizer.hasMoreTokens()) {
                String word = tokenizer.nextToken();
                if (wordStrength(word) == 100)
                System.out.println("100 letters old: " + word);
            string = in.readLine();

    static int wordStrength(String word) {
        int strength = 0;
        for (int i=0; i<word.length(); i++) {
            int charStrength = Arrays.binarySearch(WEIGHT, word.charAt(i));
            if (charStrength >= 0)
                strength += charStrength+1;
            return strength;

This application was easily created using NetBeans 6. And then I copy/pasted articles from my favorite news sites in a file, passed it as command-line argument by right-clicking the project, selecting "Properties" and specifying the file name in "Arguments".

Hit F6, and voila got more than 10 words :)

Technorati: netbeans school assignment

Wednesday Jan 09, 2008

Meet Agraj Mangal - Sun Campus Ambassador for Delhi University

As mentioned earlier, we have recruited a new student under Sun Campus Ambassador Program.

Meet Agraj Mangal - a student of Masters of Computer Applications  (equivalent to MS Computers but a 3 year program) from Delhi University. He has already started a blog - Kreativity Personified. If you are a student and would like to learn about Sun technologies then subscribe to his blog and have fun in the "quest of learning and sharing knowledge".

I met him when I presented on GlassFish @ Delhi University last year. He was selected after an intensive interview process after that. I'm glad he got selected cause he certainly impressed me with the short interaction at the University. I think he is going to be a great ambassador for our technologies. As first "assignment" in his new role, all the students in the Computer Science Department are already using  GlassFish and NetBeans for all their projects. So these students will already be GlassFish and NetBeans-enabled when they graduate.

Agraj has already started Java User Group and Open Solaris User Group in the University. Please feel free to bug him for any GlassFish and NetBeans related queries :) In order to help Agraj with his GlassFish quest, I'll create a "GlassFish For Schools" packet.

Read more about why Sun started Campus Ambassador program and other interesting details here.

Technorati: education school college sun campusambassador delhi glassfish netbeans

Wednesday Dec 05, 2007

Sun and Academic Institutions Together

I presented on GlassFish and related technologies (Metro, JRuby-on-GlassFish and jMaki) at the Department of Computer Science, Delhi University earlier this week. A more detailed blog describing that visit will be published later. But this blog is an attempt to create a summary of the main efforts that Sun has to offer to academic institutions.

The complete portfolio of Sun programs and solutions for the educational and research communities is listed here. More specific details are given below:

  • Sun Software Programs for Education - Offers special discounts to Education community on software licenses, training and software support
  • Sun Technology and Academic Resources (STAR) for Education and Research - STAR provides grants, collaborations and technology resources to educational institutions.
  • SDN Academic Developer Program empowers Academic Developers through sharing, collaboration and open innovation. It offers tools, resources and communities in which to participate and share.
  • Sun Academic Initiative is a program designed to introduce students to Sun technologies and equip them with skills in their chosen fields of study. The students get access to
    • Latest Sun technologies
    • High quality instruction and curriculum and course paths that lead to certification
    • Courses that can be integrated into degree program

    Read the entire program guide here. Apply for Sun Academic Initiative here.

  • Campus Ambassador (CA) program provides extensive training to a chosen student from a University on different Sun's open technologies including Java, NetBeans, GlassFish. This allow students to lead Sun's open source developer community in campus, run demos, promote Sun training events on campus and Sun tools to faculty. The chosen CA is paid a stipend :)
  • Student Zone provides details for students and new graduates. This page also lists country-specific events, for example Sun India University Program.
  • Sun's Real-world technology courses that earn you a certificate.
  • Subscribe to Sun Student Connection monthly newsletter. It provides you latest news on open source developer tools, technology resources and a range of developer topics.

Finally, get started by submitting resume. Hope you find this useful!

Technorati: education school college sun opensource academic


profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« July 2016