All posts by tgenedavis

Basic Java Object Oriented Programming

Java was written around the concept of Object Oriented Programming. That’s OOP for short. To understand Java programming, it’s useful to know what is meant by “objects” and “object oriented.”

Let’s explore objects by using the example of a car. A car has an owner, gas, and the ability to move. A car is an object. Objects encapsulate identity, state, and behavior. In the case of our car, the car’s identity might be Tom’s car. It is in the state of having a half tank of gas. Also, one of the car’s behaviors is its ability to accelerated so it is moving or braking to a stop. Continue reading Basic Java Object Oriented Programming

Practice Computer Programming Problems

The only way to learn a language, whether it is a spoken language or a computer programming language, is to practice. My favorite way of practicing a new language, such as Java, is by visiting one of the many sites designed to present challenging computer programming problems, and write code to solve those problems.

Project Euler
Project Euler lists fun and challenging mathematical and computer programming problems for all levels.

Continue reading Practice Computer Programming Problems

Anatomy of Java Programs

For a quick example of setting up Eclipse and creating a Java program, check out my last tutorial. That tutorial explains the benefits of using Java as your primary programming language, and writing your first Java program. There are literally thousands of programming languages out there, but Java is a strong versatile language for doing most types of computer programming in.

As mentioned in my last Java tutorial, Eclipse is an IDE used for creating Java programs. When you open Eclipse, you choose a workspace to develop in. Workspaces are just folders  on your computer. Usually, a workspace contains projects that represent a program related library.

You can create  as many workspaces as you want and only place related projects in workspaces together. For instance, you might have one workspace for school assignments, and another workspace for work tasks.

Anatomy of a Java Program
Java applications are created in workspaces that contain projects or programs. Programs are made of packages, and packages contain classes. Classes contain methods that contain the actual Java commands.

Continue reading Anatomy of Java Programs

Begin Programing Computers with Java

Anyone can program computers for free. Even if you have absolutely no experience and no idea how to start programming, you can learn to program computers. I started out knowing nothing about computers, and now have 20 years of professional programming experience on top of 10 more years of programming for fun.

You can have the same success I’ve had at programming computers. You only need to start learning, and consistently practice what you learn.

Continue reading Begin Programing Computers with Java

New English Shogi Books

Shogi is not nearly as popular as I’d like it to be in English speaking countries. Most shogi enthusiasts feel the game should be at least popular enough that chess enthusiasts have heard of it. But alas, even most geeky chess players have never heard of shogi or Japanese chess.

A side effect of the challenge of finding shogi players in America and other English speaking countries is that very few shogi books are published for English speakers. I generally buy every English shogi book I can find, and often have a complete collection of every published magazine and book written in English.

Today, I was glad to discover my shogi book collection is once again out-of-date. I was glancing at Amazon and discovered two new English language shogi books I don’t own. It was all I could do to prevent myself from whipping out the already overused credit card and purchasing them on the spot.

Amazon Shogi Book Suggestions
I spotted some new shogi books on Amazon’s site.

Continue reading New English Shogi Books

Computer Programming Tutorials Migrated

I finished migrating my shogi web pages a while back. Now I have also migrated all my computer programming pages. Each tutorial is its own blog post. I’m still figuring out what to do about my applets since WordPress hates embedded programs.

I think my next goal is to write a whole bunch of Java and Clojure tutorials. If there is part of Java or Clojure that you would like a tutorial on, contact me on Twitter @TGeneDavis . Just DM me, and let me know your needs. If it catches my interest, I might be persuaded to post a tutorial on this blog.

-T. Gene Davis

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

JSR-231 passed the Final Approval Ballot stage. Did you know Quake 2 has been ported to Java using JOGL? Here’s the website. The JOAL sound appears to be working now, and the graphics are great!. Welcome JOGL gaming!

Author’s Note (very old and unlikely needed): If you experience an “Unable to lock surface” error when running the code samples in this book, try backing out the JOGL build you are using to an April 2004 1.1 release and that should clear up your issue.

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis Continue reading Table of Contents: Learning Java Bindings for OpenGL (JOGL)

Appendix D: The JARs, Sources and a Brick Texture – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Appendix D: The JARs, Sources and a Brick Texture

Where is here?

I’m assembling the source and pre-compiled classes and/or JARs here that I made for the book. Also at the bottom is
the texture I made for chapter nine. Feel free to use or modify this code, but remember it is provided on an “as is” basis.

Examples for chapter 1

ch1.zip has some very basic JOGL apps with source and classes. Also, the ‘read_me.txt’
file contains instructions for running the compiled classes. If you want
code to help you determine if JOGL is installed properly, look at the HelloWorld class and java source file.
(‘ch1.zip’ updated June 2007)

Examples for chapter 2

ch2.zip contains samples of using trig with JOGL. Both classes and source code are
included.
(‘ch2.zip’ updated June 2007)

Examples for chapter 3

ch3.zip contains several loose class files as well as the bouncing example and the dial
example code and classes.
(‘ch3.zip’ updated June 2007)

Continue reading Appendix D: The JARs, Sources and a Brick Texture – Learning Java Bindings for OpenGL (JOGL)

Appendix B: OpenGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

This list of links is no longer maintained, but may give a starting point for searching for JOGL resources. 

Appendix B: OpenGL Online Resources

Various Web Resources

These links are all to C or C++ tutorials on OpenGL, but if you squint really hard it will look just like Java. So don’t let any C like gibberish put you out.

OpenGL Home Page: The Industry’s Foundation for High Performance Graphics

http://www.opengl.org/

 

OpenGL Survival Kit Tutorial by Nicole Deflaux Terry

http://www.cs.tulane.edu/www/Terry/OpenGL/Introduction.html

 

“Game Tutorials: Game Programming with Personality, From Start to Finish”

http://www.gametutorials.com/Tutorials/OpenGL/OpenGL_Pg1.htm

Continue reading Appendix B: OpenGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

Appendix A: JOGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

This list of links is no longer maintained, but may give a starting point for searching for JOGL resources. 

Appendix A: JOGL Online Resources

Various Web Resources

The JOGL Project

https://jogl.dev.java.net/

 

JSR 231: Java™ Bindings for OpenGL®

http://jcp.org/en/jsr/detail?id=231

 

The JOGL Project Forum

http://192.18.37.44/forums/index.php?board=25.0

 

“Jogl – User’s Guide”

https://jogl.dev.java.net/nonav/source/browse/*checkout*/jogl/doc/userguide/index.html?rev=HEAD&content-type=text/html

Continue reading Appendix A: JOGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

Chapter 3: Animations – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Chapter 3: Animations

Java Thread Review

Hopefully you’ve used threads before, but I’m going to give you a brief refresher course just in case it is dim in your memory. Threading in pretty much every language comes in two varieties.

One type of threading is to have a timer that acts like an alarm clock. You set it up to go off at some regular interval. In Java, this type of threading can be accomplished with the java.util.Timer class.

Here is a brief example of Timer’s use.

import java.util.*;

/**
 * This sample shows the creation of a Java
 * Timer object. Timers need a task and a
 * set time to wake up and do that task.
 */
public class TimerExample {

    public static void main (String args[]) {

        //our timer
        Timer alarm = new Timer();

        //our task (really a TimerTask object)
        TaskExample te = new TaskExample();

        //we schedule the Timer to wake up
        //and do 'te' ever 2000 milliseconds
        //(every two seconds)
        alarm.scheduleAtFixedRate(te, 0, 2000);
    }
}

Next we have the actual task to perform.

import java.util.*;

/**
 * Timers need a task to perform. Like we need
 * to go to school or work when our alarm
 * clock goes off, the program needs a task
 * to do when it is woken up.
 */
public class TaskExample extends TimerTask {
    /**
     * The task is placed in the run method
     * and performed whenever it is scheduled
     * to do something.
     */
    public void run(){
        System.out.println("Wake up!!!");
    }
}

The other type of thread is used to do something right away. It is created in Java by using the java.lang.Thread class.

Continue reading Chapter 3: Animations – Learning Java Bindings for OpenGL (JOGL)

Chapter 2: Using What We’ve Seen – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Chapter 2: Using What We’ve Seen

Coordinate Systems

There is no sense in waiting until you know the best way to do things before using OpenGL. Sure you’re going to find out a few months later that there was a better way to do this or that, but you’ll never get to that point if you don’t use what you’ve learned. We’re going to take that principle to heart and start off showing you that you’ve already learned a lot.

Coordinate systems may be something that you’ve banished to the darker regions of your memory along with memories of Junior High School. It’s time to dust off those memories.

Do you remember the Cartesian coordinate system? It consists of two perpendicular axes [lines]. One is the y axis and the other is the x axis.

Here is a typical coordinate system with a point mapped out on it.

ch2_coordinate_system

 

You’ll notice that there are numbers all over the place. Usually, they’re not all written out, but they’re always there. All points on the coordinate system correspond to distances along the y axis or along the x axis away from the origin. The origin is where the two axes meet. We’ve marked the origin with an O.

So we’ve indicated the position of one point on the graph. It is (6, 10). The 6 corresponds to 6 on the x axis away from the origin. The 10 indicates the point is 10 from the origin on the y axis.

Notice some positions are negative and some are positive. It would get confusing if 2 left of the origin looked like 2 right of the origin when we mapped out points. If there wasn’t any negatives how would we be able to tell where the point (1, 2) was? It could be in four different places, however if negatives are used (-1, 2) is very easy to spot. Can you find it?

If you’re lost at this point, your in trouble. Find a good introduction to geometry or introduction to graphs and functions book and plan on reading some of it. I’d recommend checking out a college book store, or maybe a big general book store. If money’s an issue, check out the internet for tutorials. There are plenty out there.

You can continue reading either way, but plan on spending time on learning about graphs.

During this chapter we will be using the coordinate system extensively. We will also cover drawing lines and the old Trig. standbys — Sine, Cosine and Tangent. Eventually in your pursuit of graphics and JOGL, you will want to become thoroughly familiar with these, but that is then and now is now. I’ll explain briefly anything that matters, and you can always use this book for reference.

Continue reading Chapter 2: Using What We’ve Seen – Learning Java Bindings for OpenGL (JOGL)

Chapter 1: Hello JOGL – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Chapter 1: Hello JOGL

First There Was OpenGL

For some years now, a programmer that wanted to create a graphics intensive program that could be sold to users of different Operating Systems had one choice — OpenGL. The GL stands for Graphics Library. OpenGL is a registered trademark of SGI. OpenGL manifests itself as a cross platform C programming API. In reality though, it is a hardware-independent specification for a programming interface.

Most of the reasons that people have given me over the years for the lack of a future for Java especially in the gaming industry was that you can’t use OpenGL in Java. They rightly pointed out that the fastest 2D and 3D applications use OpenGL.

OpenGL is for making graphics. It is fast. Most of the time it is hardware accelerated. It seems that OpenGL can do anything visually that you would want to do.

Unfortunately OpenGL is written for C. Let’s face it, C is not the most popular language for programming complex applications. One of the biggest drawbacks to OpenGL is that you can’t make it do anything without a window to put your graphics in, but OpenGL doesn’t provide a means for you to create windows. This makes OpenGL hard to learn for beginners.

Luckily GLUT was introduced and made dealling with windows, buttons and events generated by users easier to add to OpenGL heavy applications. Still learning OpenGL in C or even C++ can be painful for new programmers or programmers that want to use true Object Oriented Programming.

Continue reading Chapter 1: Hello JOGL – Learning Java Bindings for OpenGL (JOGL)

Java Lambda Expression Basics

Java 8 introduced Lambda expressions. Lambda expressions are a shorthand for implementing single method interfaces. By a single method interface, I mean something like the following.

package com.tgenedavis.lambda;

public interface Flower {
	public void bloom();
}

The interface Flower has a single method called bloom(). Before Lambda expressions, we could implement single method interfaces with an anonymous class or with a normal class.

Continue reading Java Lambda Expression Basics

Java pass-by-reference and pass-by-value

The question often arises, “Does Java pass-by-reference or does it pass-by-value?” meaning when an argument is passed to a method in Java, is it the memory address of the variable given to the method, or the value of the variable that is passed to the method. What happens when you change the values of the arguments passed to a method?

Without getting into discussions about the virtues of functional programming versus traditional object oriented programming, let’s answer the pass-by-reference or pass-by-value question.

Java uses pass-by-value. This gets a little confusing with objects, but we’ll stick to primitives for the moment. Java passes copies of variable values to methods. When passing primitives to methods, such as ints and bytes, any changes to the values of the method arguments are only of local scope to the method.

Continue reading Java pass-by-reference and pass-by-value

C conversions between Hexadecimal and Decimal

Here is some C code I threw together back in 2001 for converting hexadecimal to decimal, and converting decimal to hexadecimal. It isn’t really complex code, unless you need it now and you haven’t done it before. The best use for this code is to compile it and use it as a command line utility with your favorite OS.

For your convenience, here it is.

Continue reading C conversions between Hexadecimal and Decimal

OpenGL in Cocoa

copyright 2001 by T. Gene Davis

One of the exciting things about Mac OS X is its tight integration with popular cutting edge technologies. One of those technologies is OpenGL. OpenGL is a software interface that assists easy and quick development of 2D and 3D images and enviroments. It is used for modeling by engineers and some of the coolest 3D games. It can also be used for more mundane 2D endevours.

Much of a program written in c using the OpenGL interfaces can be ported as is to new platforms. Only the actual window construction and keyboard/mouse events need to be rewritten. This may be defined in a system dependent fashion. GLUT (OpenGL Utility Toolkit) fills in where OpenGL leaves off. GLUT simplifies common tasks like opening windows, listening to keyboard event, listening to mouse events and drawing useful 3D objects, and best yet, does it in a system independent manner. Mac OS X has a GLUT framework and an OpenGL framework. (Again–very cool.)

There are a few hoops to jump through to get OpenGL and GLUT working in a Cocoa application, but after those are learned it isn’t that difficult to use Cocoa for OpenGL work in general. You’ll find that any tutorial or book on OpenGL or Cocoa can take over the training from there. One restriction is that OpenGL is c not java, so if you wish to use OpenGL in a Cocoa-java app, expect to brush up on you JNI.

Continue reading OpenGL in Cocoa

Objective-C on Mac OS X

a tutorial for real beginners

copyright 2001 by T. Gene Davis


Hello world!

So you want to learn to program. Better yet, you want to learn to program an Apple computer. Well you’re in the right place. You can get all kinds of cool development (“development” is just a fancy term for “programming”) tools free for your apple.

You too, can install for free Perl, Tcl, gcc(cc in this case), Project Builder and other tools. There are actually so many choices of how to learn to program for Apple computers, that the number of choices can be a stumbling block. Also, most of the tutorials already out there are not geared toward new Mac X users that don’t already know how to program. The key problem is that when you’re the knew guy on the block, you need more simple examples to help you than the Senior C++ Core Engineer with the PhD. would need, and PhD types don’t generally think slow enough for the rest of us to keep up.

So here you will find a set of tutorials to get you started, without scaring you (too much). This is not at this typing printed in a real book anywhere, so feel free to contact your favorite publisher and force them to publish tutorial : – ) .

Continue reading Objective-C on Mac OS X

Printing with Java

Copyright 2005, feel free to reuse the code in any way for free under the terms of version 2 of the Apache License. This code is presented “AS IS” with no promise it will work.

If you’re looking for an easy to use Java printing library, try GDSPrinting on Source Forge.

Welcome to Java Print Hell

Java and printers don’t mix. It’s like stirring oil and water. You can keep stirring hoping the job will succeed, but it never will. It just doesn’t work.

Java and printers are the same way. You get two options when you wish to implement printing from a java program, java.awt.print and javax.print. The java.awt.print package was added back with java 1.2. The javax.print package was added with java 1.4. The first gives you raw low level control to print. The second gives you industrial strength printing options with (currently) inaccurate examples. Both are lacking in the detailed tutorial arena. Neither gives programmers what they typically want, a quick easy way to print text.

Who’s fault is this? Sun’s of course. They’ve dropped the ball on printing from java. I’d love this paragraph to become out dated.

Continue reading Printing with Java

com.genedavis.util.GDBytes

This class is for the converting of unsigned bytes, represented by ints to signed bytes or going the other direction, signed to unsigned.

Java lives up to the Perl mantra of making simple things easy and hard things possible. One example is network protocol implementation. If you’ve implemented one in java, you’ve probably dealt with the small number of primative types that Java offers over c or c++. Normally this is a plus, IMHO, but not when doing low level work. Signed byte to unsigned byte conversions, or visa-versa, are the most used low level trick you’ll need.

You can use these two static methods to do the conversion, or just look at the source and copy the code. It’s not much code, just not well documented in most Java textbooks that I’ve seen.

Continue reading com.genedavis.util.GDBytes

com.genedavis.util.ClassLoaders

This class is for the loading of classes dynamically that are not in the class path. Feel free to reuse this code.

Typically I use it like this. I write an interface that is not in a package. Then I write classes that extend that interface. I put them in a subfolder in the program that I’m writing. I then search that directory at runtime for any classes. I try to load them using com.genedavis.util.ClassLoaders and then try casting them to the interface type I implemented them as. If that all works, I then use them to extend the program I’ve written.

Continue reading com.genedavis.util.ClassLoaders

com.genedavis.io.SystemInputReader

I wrote my SystemInputReader sometime around 2001. There are easier ways of doing this now, but I know some people used to find it helpful, so I’m re-posting it here. Scroll down past the old example to see the new way of getting console input.

The SystemInputReader class contains a method for reading the next line of text from the keyboard as a String. It does block waiting for a return, so if your program needs to be doing other stuff, throw this into a separate Thread.

Continue reading com.genedavis.io.SystemInputReader

Comparing Strings in Java

A common mistake by new Java programers is using == for comparing Strings. Often the results are correct when using the == comparison with Strings.

String s1 = "my string";
String s2 = "my string";

if ( s1 == s2) {
	// this comparison evaluates to true
	System.out.println("Why not use =='s ?");
}

After all, == works for comparing ints. Not only does it work, but it is the correct way to do primitive comparisons.

Continue reading Comparing Strings in Java

Passing User Events to Clojure from Java GUIs

copyright 2010 by Terrance Gene Davis

So you want to create a complex GUI to stick on the front end of your Clojure application. You might have noticed that there are not a lot of Clojure GUI development tools out there. That’s fine. Clojure plays real nice with Java, and Java has lots of GUI creation tools.

My favorite Java GUI creation tool is JFormDesigner. It doesn’t cost much, and has a lot of power. After creating a GUI with JFromDesigner (or your favorite GUI design tool) it is relatively painless to integrate your Java GUI with your Clojure application.

Continue reading Passing User Events to Clojure from Java GUIs

Real Geeks Assemble: Beginner Assembly Part 2

Beginner Assembly Language for PPC Darwin

(oh, and Mac OS X too ; – )

copyright 2003 by Terrance Gene Davis

Hello there!

Those of you who have written any programs in other languages, have run across the famous “Hello world!” example. Usually it is the first example that is done in an unfamiliar language. At the day job, whenever someone gets a rudimentary example of some new software technology working they mention that they have a “hello world” done.

So why did I not start with a “hello world” in the last chapter? It would have been too complex for the first chapter. But now that you’ve seen some basics, here’s your example.

Continue reading Real Geeks Assemble: Beginner Assembly Part 2

Real Geeks Assemble: Beginner Assembly Part 1

Beginner Assembly Language for PPC Darwin (oh, and Mac OS X too ; – ) copyright 2003 by Terrance Gene Davis

Real geeks assemble.

This is a beginner’s guide to programming using assembly language. It is aimed at users of Darwin for PPCs. That includes users of Mac OS X. Some knowledge of C would help too. Way back in the days of the Apple ][ (for those who were out of diapers) there were many books on low level programming of the Apple. They spanned Disk Operating Systems, Hex (yes, actual hex) programming and a whole host of other low level things that real geeks like to freak out their friends and neighbors by talking about. This was the golden age, when C programmers were considered wimps. It was a great time. The books back then were written by enthusiasts for enthusiasts. They were chalk full of jokes (cryptic jokes true), they were fun to read, and had cool examples. Like how to have a disk announce it belongs to you when you boot from it. I don’t think we can bring that back, but here’s a little relic. Continue reading Real Geeks Assemble: Beginner Assembly Part 1

Apache HTTP Server Version 2.0

Intro Apache Mod

Credits: This document was written by Terrance Davis at the request of emWare, Inc.  (www.emware.com was a device networking company), and released with permission to the Apache community in 2002.

This seems to be accurate as of Apache 2.0.39. At least it will give a good starting point into what has traditionally been a sparsely documented area of Apache. This document is written from the Unix perspective, but should not need much modification to work under other platforms.

In the past it was been very difficult for coders unfamiliar with the guts of Apache to get a start on making custom mods. Currently (July 2002) this is even more difficult because, though Apache 2.0 is shaping up nicely, the documentation available to the public has not caught up. I spent a lot of time reading comments in the Apache source code while researching this document.

Let’s start by jumping into the friged waters head first. Let’s make a mod.

Continue reading Apache HTTP Server Version 2.0

Simple Java DOM XML Example

copyright 2004 by Terrance Gene Davis (http://genedavissoftware.com/)

A Simple XML Document

Unfortunately DOM XML documents in Java have a reputation for being
hard to create. This simply isn’t true. The construction process is
very wordy though, but if you have a cheat sheet (like this tutorial),
then they really aren’t so bad.

I’m going to show you a base example that does everything that most
documents need to do. It has a root element. The root contains
another element that is its child. The root contains a comment too.

Continue reading Simple Java DOM XML Example

Implementing Runnables the Lambda Way

Java 8 introduced Lambda expressions. We’ve been told they would bring simpler easier-to-read programs. We’ve been told that Lambda expressions create multi-core friendly code. Functional programs created with Lambda expressions have fewer bugs, saving development time and maintenance costs. Rumor has it that the release of Java 8 was the moment when the rise of the oceans began to slow and our planet began to heal; it was the moment when we ended all language wars and secured Java’s image as the last, best hope on Earth.

I’m not saying it’s all true. That’s just what I’ve heard.

To decipher rumor from truth, we need to start with some basics. There is a lot of complex, albeit cool, stuff that the experts can do with Lambda expressions. We’ll start with a basic tutorial on how to use a Lambda expression to implement a Runnable.

Continue reading Implementing Runnables the Lambda Way

Shogi Pages Migrated, … Time for Lambda Fuctions

It took a couple of days, but all my old shogi pages are posted to this new site. I looked into putting my shogi applet up, but my provider doesn’t permit applets. I am looking to migrate it to a Google app, but that will take time. On the bright side, all the tsume puzzles, shogi PDF boards, and rules are up on this site.

Next up, I will start migrating my old computer tutorials and updating the ones that make sense to update. I think I’ll take a break first, and write a tutorial on higher order functions in Java 8. I don’t think most established Java programmers realize what a big deal lambda functions are.