J2EE Version 6

Sun Microsystems is coming out with the next edition of the Java 2 Enterprise Edition. I read a lengthy article about the new features in this framework. Here are some of the goodies that Sun says is in J2EE 6.

There are profiles which support a subset of the J2EE standard, allowing for lean deployments. Next is the idea of extensibility. Basically they are providing a way to include plugins into the system.

There is a JAX-RS API which helps you develop RESTful web services. There is also bean validation. This is a standard mechanism to perform data validation before saving to a database.

Asynchronous processing of beans is built in now. J2EE will also now support AJAX. There is a scaled down Enterprise Java Beans release called EJB lite.

Another technology is JPA, which stands for Java Persistence API. Finally there is a Criteria API which is a way to query objects. I myself do not have any experience with J2EE. However the Java dudes consider it essential. So you know I will be learning the basics soon.

Disappointing Advice

This semester I am taking a web development class in school. We are learning HTML and Cascading Style Sheets (CSS). However next semester I shall take an advanced Java programming class. I thought I had better brush up on my Java programming since I had not done any since my intro to Java class.

I thought I could combine what I learned in web development with some Java code to produce a Content Management System (CMS). It would take user input and spit out a blog site in HTML. This seemed doable in a month or two if I kept the app simple.

Today I read an advice column from a developer claiming to be a veteran who was in the know. He started out by recommending that developers do not create CMS systems. Ooops. He went on to say that developers should not code in Java. Ouch. That was the double whammy.

The reasons for this advice were twofold. First there are too many existing CMS solutions on the market. Second he said users just don't use Java apps. Well that might make sense if I was trying to start up a business with my product. But I am just trying to write a throw away app to gain some experience. So I think I am okay with my idea. It just won't turn into some money making opportunity. Or will it?

Build Speed

What is hot in the world of Java right now? Well they are determining the contents of Java 7. However an article I just read focused on how Java build are getting fast.

The most frequently used build tools are Maven and Ant. That comes as no surprise. The Java guys I know recommend these tools.

Incremental builds bring build time down to 30 seconds or so. Incremental means you only rebuild what is needed due to recent changes in code.

Here is something I have only remotely heard about. Automatic builds triggered by code checkin are on the rise. I know some frustrated developers on my project wish we had that. Builds are getting painful on my project.

One build idea that has just not taken off is building using cloud computing. I guess a lot of the cloud is just some hype and marketing. You can trust a technology unless it is being used in the trenches to solve real problems.
Previously I had written about some benefits of the Java programming language. However some people just love writing code in Java. I have worked with many of these people. They will invent up projects just to write some Java. They work extra hours as long as the app is written in Java. Craziness I tell you.

Well I read up on some reasons why people love Java. One is that there is industry standard certifications you can learn. You can tell whether somebody has a least a little Java knowledge by the certification they possess.

Java is also a popular language. You can always find a Java developer for your project. And you can find some supporters for Java in any group of developers out there. Although I have not personally experienced this, I hear Java gives good conferences.

The Java programming language is easy to learn, especially if you know an object oriented language like C++. It is a general purpose language which can fit many needs. And there is one final reason to love Java that can be summed up in one word - Eclipse. Now I won't say that I love Java just yet. But I am slowly warming up to it. I need to write some enterprise application before the final verdict is in for me.

Benefits of Java

Recently I blogged about some people hate Java. However there is another side to the story. For every person who dislikes Java, there are probably 5 who love it. I just read a discussion on what people like most about Java. I found the results to be most interesting.

A key factor in people liking Java is the run anywhere capability. To my surprise, some people also said they liked Java because it is fast. I am not sure if that referred to a fast run-time experience. Or maybe it had to do with rapid application development.

Deployment is easy with Java says some folks. I found that not to be true. However my limited experience with Java may have skewed my feelings. People also love that the libraries are well documented.

Here is something I can appreciate. Java programming makes good money. You can't argue with that. Let's hope this environment is also sustainable. Many programmers know Java. You can write Java code and expect people to be able to maintain the code.

Well there is much more love out there. I will pick up with this list in my next post.

Java History

I started learning how to code in Java this year. It is like I arrived very late to the party. I just hope the party is not over. Now it is not like I never heard about Java over the years. I just did not get into it until now.

I read a humorous post that reflected back on Java from the beginnings. There is a lot to the history. However I found many of the milestones were events that I heard about.

Java actually started out as the Oak programming language. The name was switched to Java. The Java 1 developer's conference had a mighty turn out. Version 1.1 of the JDK had JDBC for database connectivity.

Java 2.0 came out. Then there was Enterprise Java beans. I recall the C++ programmers on my project getting excited about EJBs when they first came out. Then the excitement died down. To tell the truth, I don't really know much about EJBs. I assume they are a way to store data you get from the DB.

Web services got hot in the Java world. I also recall the craze where every team on my project wanted to publish some web services. That was short lived though. I saw a metric that 75% of developers used Java back in 2003. I wonder if the number still hold true.

Another metric I spied was that 4.5M developers use Java today. That's a heck of a lot of people. What is the future of Java? I read an article every now and then about problems with Java 7. Time to get familiar with the new Java landscape. Perhaps this party has really only just begun.

Don't Be Hatin

I read a whole discussion on why people hate the Java programming language. This was strange. Normally I hear people saying they hate things like C++. Most of the hard core programmers I know actually like Java. So I thought I would expose some of the hate themes.

A common complaint about Java is that it is verbose. I can understand this perspective as the new hot functional languages seem to get a lot done in a one liner. There is also the age old complaint about poor Java based performance.

One particular complaint is one that I share. Java is all about many frameworks. I don't like it because you need to learn all the frameworks before you can call yourself a real Java programmer. The language is also associated with rampant design pattern abuse. Nuff said on that.

Here is something I found odd, and that others hate about Java. You are limited to one class per file. WTF? Shouldn't the programmer be able to make that decision? Another drawback is that you don't produce executables with Java. That is both a love and a hate I would guess. The consensus is that Java is poised to keep the enterprise market locked up. If you work for a big company, or more importantly you work on a big project, chances are you will code in Java.

Java Trivia

I saw an old timer ask what the first four bytes of a Java class file are. Who knows? Who cares? It turns our the answer is 0xCAFEBABE. I tell you what. That does not seem to be a very important fact, unless you are trying to clone javac.

Well this random piece of trivia does not seem relevant to the world of Java programming. However it is a neat way to identify Java class files (aside from the .class extension). Perhaps this is more of use to file scanners and such.

Perhaps this is an invitation to break out a hex file view and see what is really in those .class files.

Scanner Troubles

I got ahold of this text file that was the content of the ZF05 zine. My goal was to write a program to extract the good parts of the zine for me to read quickly. Of course I was writing my program in Java.

My process was to do some Test Driven Development. So before I wrote the complex algorithms to do smart filters, I decided to write some simple I/O operations first. To do this I employed the Scanner class in Java. That should be easy. You pass the Scanner constructor a File object. Then you keep calling nextLine() as long as there is a hasLine().

My first TDD exercise was to write a copy program. It should just take a file and duplicate its contents to a second file. That sounds easy. My first attempt compiled quickly. But when it ran, it only copied part of the file. I thought perhaps it was some type of buffer overflow. However no exceptions were through. The program ended gracefully. I put my debugger hat on. Then I determined how far the copy was getting in the source file. That when I discovered some strange characters in the source file. They seemed to be causing hasLine() to return FALSE prematurely. It is going to take some digging into the Scanner class to figure out why I was getting this false positive. For now I will just give you some lines around the place where hasLine() choked. See if you can see why it is failing:

-rw-r--r-- 1 thalakan thalakan 386 Jan 5 2006 zeller.cd
rwxr-xr-x 2 thalakan thalakan 512 Jun 22 2006 かたかã�ls
$ cat watcher.pl
#!/usr/bin/perl -w

Java Virtual Machine

I just read this blurb that the Java Virtual Machine will support languages with dynamic languages. Huh? Is Sun saying that Java will have dynamic typing. If so, why don't they come out and say so instead of talking about the JVM?

The truth behind this strange statement is that the JVM is not the same as Java. The JVM is a program which executes byte code. Java is a programming language. Now it just so happens that Java gets translated down into bytecode, and the JVM runs that code. However the key is that other languages can be translated into bytecode as well.

I understand that a flavor of Lisp has a compiler which translates the source into bytecode. It currently runs fine in the default JVM from Sun. Who knows? Maybe Sun Microsystems is looking to release some other important programming language. For now I am concentrating on Java.

Larry Ellison Drops By

Have you heard the latest news? Larry Ellison, CEO of Oracle Corporation, dropped by to address the crowd at JavaOne this year. He assured Java developers that Oracle will support Java. There is just one problem with that. Can you trust Larry Ellison? I mean we are not talking about Larry Page here.

I do believe Oracle actually uses Java though. Originally you would code stored procedures in their proprietary PL/SQL programming language. However as the Internet and Java got hot, Oracle added the ability to code stored procs in Java. Nice touch. I still don't trust them.

Scott McNealy, chairman of the Sun Microsystems board of directors, concurred that Oracle has spent a lot of money on Java. In fact he stated that Oracle spends more money on Java than any other company. Perhaps they shall protect their investment. The hard part in buying all this is that the Oracle database is Oracle Corporation's true investment, not the Java programming language.

JavaOne Contest Dud

Sun Microsystems hosted a contest that turned out sour for me. You had to blog about JavaOne 2009 technical sessions. I did not attend JavaOne. This was not supposed to be a problem as they post the technical sessions online.

I opted to view the JavaOne technical sessions as PDF documents. Sun makes you sign up for their Sun Developer Network (SDN) to view the PDFs. This seemed like a hassle. But it was free so I decided to go through the motions. I created a new account. The directions told me to respond to an e-mail to confirm my address.

Here's the thing. I never received the e-mail. It is bad enough that I had to go through these hoops to access the technical content. But some glitch resulted in the process not working. Yeah I could try again. Why should I? This is going to take some time and might not even work again. My time is worth money. Now I don't want to blog about JavaOne technical info. Fail.

Solving Puzzles

Today I read another chapter from a free PDF downloadable book, whose chapters are all from other books for sale. Nice marketing tactic. This chapter was from a book called Java Puzzlers by Joshua Bloch. There were a number of words of wisdom contained inside.

For example, the + operator means string concatenation only when at least one of the operands is itself a String. Otherwise you get addition.

Here is another example stressed by my Java programming class instructor. The == operator tests whether two object references refer to the same object. It does not test whether the two objects contain an equivalent String. To do that requires the equals method.

We really did not get down to how the Java compiler works in my class or the book I read. However I found out that there are multiple passes. One of the first passes is translation of escape sequences. After that tokenization takes place.

Let me end with some tips that are not specific to the Java programming language. One is to not leave code commented out. Just delete it to prevent comprehension problems. The other is to avoid case statements within a switch statement to fall through to the next case. That is just bad practice.

Effective Java

While browsing around the net, I came across this free Java book. It was a PDF whose chapters each contain samples from other books. One such sample chapter was from Effective Java by Joshua Bloch. The second edition of this book came out last year. The first edition was from back in 2001.

Although Bloch now works for Google, he came from Sun Microsystems. This is why he is intimately familiar with Java and the Java API. The book has a list price of $49.99 like the first edition. How you can find discounts at many places like Amazon dot com.

Here are some interesting ideas I got from Chapter 2 of the book. The first is that of a static factory method. This is a method which is static. It returns an instance of the class. This technique has a number of advantages over a normal constructor. This is not to be confused with the Factory Method design pattern.

One thing I found surprising was talk about the protected access modifier. When I learned Java, I was only taught about public and private. However now that I think back upon it, someone in my class who already knew some Java asked whether "protected" had been removed from Java. Unfortunately the instructor did not know the answer.

Another pattern described is the Builder pattern. This is a three part process to initialize objects with a subset of all possible parameters. First you get a builder object. You then call setters on this object for the optional parameter you wish to set. Then you call the build object which uses the properties you set, and generates an object for you.

Finally there is a call for developers to remember to null out references to objects that are obsolete. This is essential to prevent memory leaks. Yes there is potential for memory leaks in Java, especially when you are managing your own objects as in a stack.

Code Viewers

I just a neat blog entry by SteveChy on an alternative way to display Java code. Check out the example image he provided. Better yet, read the post yourself at his Free Ideo Monoid blog yourself.

The general idea is to avoid colorization to specify things in your code. Instead he will use size and positioning to convey meaning. Some of the ideas looked good.

It appears that this is just a prototype. Let's hope this guy follows through and releases an app to view and maybe even edit Java code. Good stuff.

File Parsing

I have an idea for a new Java program which requires information about my colleges schedule of classes. Specifically I want to know what all the Computer Science classes are, and what the prerequisites for each are. This information is readily available in the latest schedule of classes. The chore is to get that information into my program. How do you do that? You write a program of course.

To start with, the schedule of classes is a huge PDF file. I used Adobe Acrobat to export this file to plain ASCII text. Then I wrote a small Java program to read in the file one line at a time. I coded in some rules to parse the lines to figure out which ones were computer science courses. So far I can detect all the CIS courses fine. For now I have the code just grabbing the text of the prerequisites for each class.

The next step is for me to build some structure which can easily represent the relationship between classes. Perhaps this is a big tree. I don't know. I do know that I must first read in all the information. Then I can make the connections in my tree. I already have a Java class called Course. And I have coded most of the logic into my Java class Parser. There are a lot more Java class before I have all the information that I want.

Sorry I have been a little cryptic about my eventual application which will require all this information. Perhaps when I am done I will upload the application here. For now I am keeping it on the down low. I am finding it hard to schedule time to work on my Java programming. As soon as my Java college class ended, there was nothing else driving me to code. And get this. The university does not offer a Java Programming 2 class. Go figure.

The Use of super()

This week I wrap up my college class on Java programming. We spent a lot of time on some basic Java concepts in class. That meant we had to rush through a lot of the final chapters in the book. Unfortunately we rushed through inheritance, and skipped many sections. One such section we skipped was the use of super() to reach up to a superclass.

On first glass, I assumed you had to prepend any methods of the base class when you call them from a child class. However that is not normally the case. You can just call a method. If it is defined in the super class, Java will know what code to execute normally. That is because subclasses are extensions of the superclass. That is, they have access to the same public methods defined in the superclass.

There are two exceptions which require the use of super. One of them is the constructor of the child class. If you do nothing special in this constructor, Java will call the default constructor of the parent class for you. However if you want to call one of the other constructors of the parent class, you must make that call with super().

The other occasion when you need to use super is when you have a method that is overridden in the child class. If you make a call to an overridden method in the child class, Java chooses the overridden method to execute. You might want to execute the code for the overridden method in the base class. To do that, you have to put the super keyword before the method name.


I am nearing the end of the Spring college semester. This semester I am taking a Java programming class. There was one chapter near the end of the course on exceptions. We did not spend much time on it because there is not much time left. However I am still trying hard to wrap my hands around the concept.

Exceptions are not unique to the Java programming language. I know C++ has them. And I would guess many other languages have them as well. It is straight forward how to throw and catch an Exception object. You are just passing a message. However I have still not yet found a great reason to create my own exception classes. I guess I could use them to ensure the caller can separate exceptions with different catch blocks. But aren't they all going to just call getMessage() on my object?

Here is one thing I have determined about exceptions. This also applies to any classes you write. You should not name the class with too long of a name. It gets tiring to type all those characters. Yes I know you can cut and paste. But if there is a misspelling, and there are a million characters in the name, it takes a long time to figure out where I went wrong. I am going to do a bunch of programming projects where I throw and catch exceptions. Perhaps after that I will have a better feel for them.

Good or Great

I have finished reading the chapter on arrays in Java. This is for my college class. In addition to the reading, I have completed each Self-Test question from the chapter. I have written Java programs to solve all the exercises at the end of the chapter. You could say that I have achieved a good understanding of the material.

Here comes the hard part. There are also a bunch of programming projects at the end of the chapter. However there are so many other things I would rather be doing. We are behind at work. I could catch up with this week's list of tasks to be completed. It is nice outside. I can do some necessary yard work. The weather also lends itself to me taking a bike ride with friends. The girlfriend wants to see a bunch of movies. She is also hungry and wants to go out to eat.

It is easy in the middle of the night to spend some time learning Java. The hard part is now when I really don't want to do any more Java programming. After all, I have reached a good enough level of understanding. What is there to gain by going further? The answer is that there is greatness to be attained. Now I am not saying that I will be a great Java developer. But in order to have a chance at greatness, I must push on now. It is absolutely required to do each and every one of the programming projects in the back of the book.

To tell the truth, greatness will also require going beyond the projects in the book. I need to code up some other programs using Java. You know. I need to implement some non trivial application using the Java programming language. Only then will I have a slight chance at possessing great Java programming skills. Let's see where this takes me.

Selection Sort

I have been reading ahead in my textbook. The next chapter is on arrays. To help learn arrays well, the textbook goes over a number of sorting algorithms. One exercise just had me implement selection sort.

Selection sort is one of the easiest sort methods. It is an in-place algorithm, requiring no extra space in a array other than one temporary variable to do swaps.

The way selection sort works is to traverse the array, and swap the current element with the smallest value from the rest of the array. It could not get any simpler. However this technique has poor performance if you have many elements in the array.

Constructor Calling Constructor

We just started learning about class constructors in my Java programming class. In the past, we just did the new operator without knowing what was going on. Now we are getting a little more information on the subject. There is one specific constructor issue of interest to me. That is the case where a constructor calls another constructor. My book instructed me to use the “this” keyword to accomplish it as so:

public Class Pet
public Pet()
// default constructor code
public Pet(String name)
// call the default constructor

I found this syntax to be a little strange. Yes I understand the “this” keyword refers to the current object. But we are talking about making a call to a method in the class. Why not use the name of the method like so:

public Class Pet
public Pet()
// default constructor code

public Pet(String name)
Pet(); // This does not work!

It seems logical to use the actual method name when making a call to it. However the Java designers must not have agreed with me. Calling the constructor by its name results in a compile time error. Oh well. It was worth a try.

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.

Private Date

I was trying to write a Java class for an exercise in my class textbook. The job was to model a credit card. I figured an important characteristic of the credit card is the expiration date. At first I just created an instance variable of type String. Then I figured I would need a member isExpired(). That made me thing String was the wrong type for this variable.

Off I went to the Java API. The first Date class I found had something to do with SQL. That did not seem right. Then I found another Date class in java.util. However the docs for this class did not seem intuitive. I want to set a day, month, and year. There used to be a way to construct a Date object with such properties. But it had been deprecated to favor the number of milliseconds since some start date. How random.

Since I am a programmer, I decided to roll my own simple Date class. This was just for instructive purposes. Following good programming practices, I made the day/month/year private. I got down to writing my own comparison member. That's when I really got tested with my knowledge of what private means. I pass another Date object reference into my compareTo member. Can my member access the private instance variables of the Date passed in? It compiles fine. But it seems wrong. My gut tells me I should only be able to access private members of "this" object. Time to ask my professor about these details.

JavaFX is Here

Today I was reading the latest issue of Software Development Times magazine. There was an article on JavaFX in the first couple pages. Years ago I would have skipped over it. Now my eyes are trained to spot Java related technologies and dig in.

JavaFX is a platform for rich client Java applications. They can run as desktop or web applications. It is a late comer to the rich Internet application scene. AJAX, Adobe Flex, and Microsoft Silverlight are the competitors. And they have all beat Sun to the punch.

Strangely enough, Sun Microsystems considers JavaFX a replacement for PHP. Its biggest benefit is the ability to use Java classes. It can run in the Java Virtual Machine. Some call the syntax similar to that of JSON.

You can use JavaFX for things such as animation and special effects. I would have thought you could use Swing for that. In fact, many of the user interface controls in JavaFX come from Swing. I am busy learning the basics of Java right now. However JavaFX might be worthwhile when I get my legs in Java basics.

Welcome to Java

I have spent the majority of my career on a single project. To stay aboard, I have moved from one company to another. This is a big government contract. After nearly 10 years, the daily challenges are still exciting.

When I first took the job, it was just what I was looking for. There were some Visual C++/MFC applications. The back end was the Oracle database that I wanted to learn. Things seemed great.

Somewhere in the last few years, the customer wanted to go to the web. This sparked all kinds of work to produce an enterprise edition rewrite of the system. That proved harder than it sounds.

Part of the rewrite was to migrate the client server applications to some Java on the back end. I was clueless on how to help this effort. Luckily it was a drastic failure and the upgrade got shelved. However it may come back from the grave. I need to be ready next time. It is now time to learn Java.