Rapid Application Development

I had a little free time at work. So I decided to quickly code up a small application to do some work on Windows. I wanted to showcase this application on the Black of Hat blog.

These days my goal is to write all new applications in Java. This will give me some good practice. However I had some strict requirements for this latest application. It needed to have a graphical user interface. It needed to interact with the Microsoft Windows Registry. Finally it needed to by done quickly.

Unfortunately I fell back to my C++ programming skills. The result was the TaskCtrl program. To tell the truth, I am not sure if Java is even able to update the Microsoft Windows registry. I have the feeling that it cannot modify the state of the file system for security reasons. Therefore I guessed that it could also not deal with the Windows registry.

Who knows? Maybe by the end of the college semester I will be able to write Java programs with graphic users interfaces. And I will be able to knock out the code quickly as well.

2D Arrays

My Java college class is moving painfully slow. I have decided to read ahead to get to the topics I need for real work. The current chapter is on arrays. I have a game which is run on a two dimensional map. This is a perfect application to two dimensional arrays.

So far my textbook has been concentrating on one dimensional arrays. There is not that much to them. It is only a little involved if you have an array of references to objects. You have to create the array. Then you have to create the objects themselves that are referenced by the array elements.

The next chapter is called Two Dimensional Arrays. That should give me exactly what I need for the game. Right now I am using the actual graphics screen to store things in my game. That is very slow. It is also difficult to do anything complex with the displays. I need 2D arrays to get my business done.

Setting the CLASSPATH

I continue to read ahead in my Java class textbook. Reading alone does not make the concepts sink in. So I try to do each and every exercise in the book. Today I had some free time at work. I decided to try one of the exercises from the section I was reading. The exercise instructed me to use a class that had a source listing in the book.

My instructor provided me with the source code for the listings in the book. This helped so I did not need to type in the code. I compiled the class provided to me by the book. Then I coded up a simple second class in another file which made use of the class from the book. However the Java compiler complained that it did not know the other class name.

This was very strange. I had already compiled the other class. Everything was in the same directory. I was at a loss. I tried to import the other class. That did not work. The other class was not in a package. I could have sworn that this worked before. If the other class is in the same directory you can use it.

Then it dawned on my. I bet there was something wrong with the CLASSPATH. I checked out the system variables and found that the current directory (.) was not a part of the CLASSPATH. I quickly added it to the beginning of the CLASSPATH. Now this makes sense. Java won’t consider code in the current directory unless that directory is part of the CLASSPATH.

Trick Question

Today at school we went over the answers of the test we took last time. There was one questions I got totally wrong. A couple people including myself grumbled that it was a trick question. The instructor said it came straight out of the book.

Here is the question: What does the following code snippet output:

int n=0;
for (n=4; n > 0; n--);

Here is a hint. There is only one line in the output. At first I protested. Surely this code should have 4 lines of output. The loop iterates through four times after all.

The trick was that there was a semicolon directly after the for loop. Therefore the loop has a body which was empty. After the loop finished, n equals 0. Then the program executes one println statement. Yeah. That's an evil question. Now I know better. Watch out for the tricks.

Sun Buyout

There have been some big rumors about IBM buying Sun Microsystems. This has resulted in Sun’s stock rocketing up 80%. Officially IBM and Sun are in talks. Word on the street is that IBM is talking about a $10 per share buyout of Sun. Since Sun is the inventor of the Java Programming Language, I wonder what effects this transaction might have on the world of Java.

IBM already owns the mainframe computer business. Obtaining Sun would give it a majority of the UNIX server market. That is what most people are focusing on. This is being described as a merger of two hardware companies.

Java has already been released as open source. However Sun keeps a watchful eye over the technology. For example, there are still some issues of Sun licensing Java for other implementations of the Java environment.

Sun provides the Technology Compatibility Kit (TCK). It verifies whether something is compliant to the Java specification. Currently there seems to be some controversy over Sun’s management of the TCK. With an IBM purchase, these reins may be loosened.

These are two large companies. So it might take a long time for a merger to complete and actually have an effect on anything. Still I wonder what kind of world it would be like if it turned into IBM Java. It might be time to call up some of my Java developer buddies to gauge their opinion.


I had an assignment from class to include a UML diagram. This was supposed to be pasted into a Microsoft Word file. Now I did not want to scribble a diagram on a piece of paper and scan it in. I also did not want to try to draw the diagram using Microsoft Word drawing tools. The best technique would be to use a tool that knew that UML was I thought.

So I looked around in Eclipse. I could not figure out how to generate a UML diagram. Now I know this is a tool for writing code. However I thought it would have such a tool. Then I checked out the latest Visual Studio that I had. This was the professional edition. But even this tool did not seem to be able to knock out a UML diagram.

Normally I use Rational Rose to bust out UML diagrams. But I did not have access to my computer which has Rational rose installed. I did not feel like searching for a free Rational Rose install as I figured it would be huge.

It was time to Google the web to see what tools were out there. My goal was to find something easy and free. One of the first hits I found was UMLet. Here are some hints on using it. You select an item on the left pane. Then the bottom right hand corner is the free form text that is drawn with that item.

UMLet turned out to be just the thing I was looking for. Later I was happy that I decided against using a graphics tool to draw the UML diagram. I had to add some more items to my class. Then I needed to update my diagram based on error I found. This was trivial with the UMLet tool. A big thank you goes out to the authors of this software. You helped me get an A on this assignment.

Name Clash

In my Java programming college class, we are learning more and more about classes. Specifically we are learning about access modifiers for instance variables and methods. One thing that is pretty clear is that if you have an instance variable in a class, and the variable name is myVar, then you cannot have another instance variable in the same class with the same variable name.

Within the class, you can reference an instance variable with just its name. You can optionally prepend the variable name with the keyword “this”. However in this scenario, “this” which represents the current object is already implied. So for most if not all of the time, the “this” keyword is omitted.

We are also learning about accessors and mutators in our programming class. Mutators, or setters, take an argument and set the instance variable to the value of that argument. Here is where some confusion in class came up. Support we have an instance variable in our class named “email”. What should we name the formal parameter of the setEmail method?

Most of the time, the simplest and most obvious variable name is the best one. So I thought I would name the formal argument to the mutator setEmail to be just “email”. But here is the problem and question. Does the local variable email, which is the formal parameter to the method in the class, clash with the instance variable of the same name?

The best way to answer questions like this is to try it out. It compile fine. So it must be ok. The only tricky part comes when you must set the instance variable to the formal parameter passed into the method. How do you do that if they are named the same? The trick is to qualify the instance variable with the “this” keyword. Then you get code that looks like this (no pun intended):

public void setEmail(String email)
this.email = email;

Now this may not be the best practice, as there might be some ambiguity as to which variable the name email refers to. So our instructor insisted that we name the formal parameter newEmail, or something else distinct from the instance variable name. That sounds logical. It was still cool to find out you could have two variables of the same name within the class.

Software Distribution

I coded up a cool quiz program on Oracle PL/SQL questions. It was aimed at helping me study for an Oracle certification exam. Now I wanted to release this program to other people to use. I did not want to just send out some Java source code. From what I gather, you can ship the Java class files. However this requires a certain version of the Java run time,

How do commercial shops roll out their software? Do they include the class files with an install that checks and optionally installs the Java Run time Environment? I come from a C++ Windows background. So my instinct is to somehow turn this thing into a self contained executable file that I distribute. However it seems this is not the Java way to go.

Maybe there are not that many users who code and ship Java applications. Or maybe there are not many desktop applications that are developed and shipped like this. It is easier if the program only needs to run on the server. In that case, you can ensure the correct version of the Java run time is installed there. You can also deploy just the class files to the correct locations. Users can then just access the program through web pages viewed in their browser.

Development in the Java world appears to be a new paradigm. I am not sure if I like it. But first I need to get with the program as far as software deliveries go. After I have tried it for a while, I may have a better perspective if it works, and whether it is a good way to go for development and delivery.

Game Success

Good news. I successfully created a simple Java game within 7 days. This was in response to a challenge posted on a Usenet news group. You can find a link to the program on the Legend of Angband web site.

The emphasis on my development for this game was to knock out something quick. As a result, I only had two classes. There was the driver program which had my main() method. And then there was a Monster class housed in its own file.

This was a Dungeons and Dragons style two dimensional game. There was no rocket science here. I drew a maze. Then I put some gold in that maze. And I added some monsters. The monsters fight you when you attack them. They follow you if you try to flee. Yeah it does not sound like much. I am still a Java novice and it has been a busy week. Download it and give it a try already.

Once You Go Static...

I am on a 7 Day Quest to write a game in Java. That's a tall order since I am only half way through a college Java class. But I am learning a lot.

For example, I am trying to conserve time due to the quick deadline. Therefore I am putting all my code in one class. This class has a static main function to run the program. Guess what? That function can only call other static functions in this class. That's not too object oriented.

Well perhaps the optimistic way of looking at this is that I have an object. But it is the only one of its kind. There is only one main. So the class with that has main must be a singleton. I am keeping some data in static variables. And I am breaking up functionality into static methods. But it still feels a little clunky.

Libjcsi to the Rescue

I have previously written about my recent exploits in the game development field. To make sure I gain Java programming skills during this exercise, I am writing the whole game in Java. So far I tried rolling my own graphics drawing code. That turned out to be difficult. Some output looked ok. Other graphics were slightly off. This was painful.

Another developer recommended that I use their graphics package libjcsi. This package covers simplifies console output for you. I tried compiling their sample program. In 10 minutes I had a graphical user interface up and running. In an hour I had a bare bones screen of my game going. I was pleasantly surprised that this package also handled keyboard input. So I quickly coded up user input to control the direction of the main character. I now got a guy running around my simple screen. Life is good.

Next I think I will try to place objects on the screen that represent gold. Then if the user walks over top the gold, I want to register that the user picked the gold up. These all seem like baby steps. But once I get the basics down, I can rocket into more complex ideas I have about my game. I will say that I still do not have the hang of Java packages. Perhaps by the time I complete my game, I will have them nailed down.

Screen Output

I am writing a game in Java called dL1. And I need to display a two dimensional grid for the user interface. After Googling the subject, I thought I would try to use the Curses library to do the output. There is a JCurses package for Java which seemed easy.

After I got into JCurses, it took a while to get the test code from the package compiled. However I could never get the test to run without aborting with an exception. I only have 7 days to complete my game for a programming contest. So I decided to roll my own graphics code.

This is a monumental task. However I already have an applet which is displaying some text. Now I need to get my vertical and horizontal positioning down. And I also need to learn how to erase graphics on my screen. But at least I have something to show for it. You can see a screen shot of my first try on my Angband blog page.

Missing Arrays

I am halfway through my college class on Java. There are a number of topics we have not covered yet. Normally that is fine, as we will eventually get to them. However I just entered a programming contest to write a Java game in 7 days. My game will be called dL1.

We have yet to cover packages, arrays, or file input/output. That is a bummer. My game will be on a two dimensional grid. That's where arrays would really come in handy. My plan is to substitute objects that references each other for arrays.

I was hoping to use some third party code to do the actual drawing for my game. So I cannot wait any more. I am reading ahead in my course book to see how to use packages. As of last night, I still had not mastered the topic. I really need to get a move on it. The contest ends in 7 days and I have one Java file which does not compile. May the Force be with me.

Garbage Collection

I read the magazine Software Test and Performance. This is because formal testing plays a large role in the project I work on. The development team does unit testing. An internal team does integration, functional, and regression testing. A customer team conducts software acceptance testing. I need to keep up with the world of testing.

A recent article in the magazine talked about the Java environment. Specifically they referred to it as managed. To me that sounds like Dot Net. They were referring to Garbage Collection. And they thought that it was a danger.

Yes the garbage collector looks after memory in the Java environment. However Java programmers just assume the garbage collector will do its job. Objects which go out of scope are supposed to be cleaned up. However if the garbage collector does not know about an object, or can't determine that we are done with it, the memory will remain unclaimed.

Some industry experts were consulted. One of them said that inefficient code leads to memory problems, even in Java. The recommendation was to be proactive in testing Java applications. The use of automation in testing was also suggested. It was stressed that any Test Driven Development cover all paths in the software.

Here I thought the garbage collection idea was a nice one. I come from the land of C and C++. It is a lot of work to manually control the allocation and freeing of memory. Java is actually a fresh perspective on memory reallocation. But with most things, you can get in trouble if something or someone other than you takes care of the hard tasks. I have learned that by dealing with frameworks for a number of years.

Java FX Mobile

Sun Microsystems has released Java FX Mobile. It is for development of Rich Internet Applications (RIAs). Java FX Mobile is based on Java Micro Edition (Java ME). As you would expect, it is similar to the desktop version of Java FX.

Java FX Mobile can run as an applet in a browser, on the desktop, or on a mobile phone. You know it is going to be targeted to mobile phones. However the beauty of it is that it also works elsewhere.

Java FX itself comes with a lot of default behavior built in. That means it should be easy for developers to produce applications which immediately fall back to defaults which work well. This is unlike plain Java, where you need to roll a lot of your own code from scratch.

There is a Java FX software development kit (SDK) available. I know that as soon as I get a handle on Java basics, I am going to want to be trying different frameworks and APIs in the Java world. Perhaps I may take Java FX Mobile for a spin.

GlassFish Portfolio

When I started learning Java, I downloaded the JDK from Sun like I assume everyone else did. There was one bundle that came with GlassFish, which is an application server from Sun Microsystems. I opted not to get it.

Sun apparently is releasing more stuff for GlassFish with their GlassFish Portfolio. This is a four piece set of products that are related to GlassFish. Now these products are not for free. I think this is one place where Sun plans to actually make some money.

The GlassFish Portfolio consists of the GlassFish web stack, Enterprise Service Bus, Web Space Server, and Management Toolkit. Before downloading the JDK and seeing the GlassFish option, I had never even heard of GlassFish. I suppose that means that not many people use it. Websphere and Weblogic seem to own the application server market. Perhaps some add-ons like the GlassFish Portfolio may help Sun try to even the gap. Alas they may already be too far behind in the race.

Java Platform Bloat

I keep my eyes peeled for any software articles about Java. Recently I read a front page article about Java Enterprise Edition 6 being very bloated. A solution is to wait for the Java Standard Edition 7 to come out. However I get the feeling that Java SE 7 is somehow delayed for a long time.

In the mean time, there is a feature of Java EE 6 called profiles. It allows you to work with a smaller subset of the huge Java EE 6 platform. Unfortunately there is only one profile available. It is the Web Profile bundle. That seems like a useful one. But it would be good if there were a number of profiles readily available.

Luckily the Java Development Kit 7 is supposed to include a feature called modules. It too will allow you to work with a smaller subset of the platform. Right now I only deal with the Java 6 SE. That alone seems large when I query the Java API. I cringe at the thought of working with Java EE 6, which is supposed to be a beast.