Deploying Programs

I checked out Java in Easy Steps from the local public library. After scanning the table of contents, I jumped straight to the chapter on deploying programs. This is an area of weakness for me in Java development. There are two ways to distribute Java programs. You can do so as a desktop application, which will require the Java Runtime Environment to be installed. Or you can do so as a web page applet. The second option will require the browser to have a Java plugin.

When rolling out a Java program, like any other installation, you need to make sure the resources required by the program are installed. The main way to include all the files you need is with a jar. Jar is a utility included in the Java SDK. You can find the program in the Java bin directory. This program has a command line interface.

The output of the jar utility is an archive file. You can run the program contained in the archive using the Java interpreter. Here is an example to create a jar file:

jar cf dL1.jar dL1.class.

Once you have the archive, you can inspect its contents using the following command:

jar tf dL1.jar

You can extract the full contents of the jar file like this:

jar xf dL1.jar

Jar creates a META-INF directory. Within that directory is the MANIFEST.MF file, also created by jar. You need to manually add the entry point for the program on the bottom line of that file as so:

Main-class: dL1

To run the program contained in the jar, you can execute the following command:

java –jar dL1.jar

Build Tools

When I first joined our project, our build scripts were written in the Korn shell. Our Korn shell programmer quit after I joined the team. Thus began our build script Hell. The scripts worked fine when everything was as expected. However they would bomb at the slightest disturbance. We needed a full time guy to baby sit this fragile set of Korn shell scripts.

Eventually a bunch of Java programmers joined the team. They decided the Korn shell scripts had to go. Being Java guys, they turned to Ant to do the builds. The result was a bit more reliable.

The Java guys got bored after a while. They started looking for ways to improve the build scripts. Maven was cited as a cool build tool. There was talk about redoing the build scripts again. However the Java guys left the project before any progress was made on that front.

It might be a blessing that we never ported our builds to Maven. I just read a rant describing Maven as pure evil. The author recommends you code your own build tool from scratch. He advises you to use Rake or Ant if you want to utilize a package. However he abhors Maven.

Here are the reasons to avoid Maven. It has the worst configuration syntax. The documentation is bad or incomplete. Maven is not flexible. It also has a broken dependency management subsystem. Exercise extreme caution if somebody tries to port your build scripts to Maven.

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.