Oracle in Charge

I needed to compile an applet I wrote a year or two ago. However I have this new laptop at home. No problem. I decided to download and install the latest Java Development Kit from Sun. Ooops. They are not Sun Microsystems any more. Oracle bought them out.

It was clearly evident from the new install program. The JDK install prominently displayed Oracle Corporation on the screen. They are the new master now. It remains to be seen whether this is a good thing or not. I do know one fact. Oracle is not going anywhere in the near future. They got profits from their databases and other offerings.

Maybe Oracle can take Java to the next level.

Guessing can be Hot

I read this blog entry by a seasoned game developer. He gives hints on how to practically come up to speed on game development. Strangely enough, he advises you to truly start at the beginning. Assignment number 1 is to write a number guessing game. My Java skills are a bit rusty. So I figured I would give it a go.

Here is the stickler. I could not recall how to generate random numbers. Sure I can look it up with Google. But a strong Java developer knows this stuff by heart. I seemed to recall Math.random once I saw it. But that is for doubles. I needed some ints. And the java.util.Random class was just what the doctor ordered.

You can instantiate the Random class without any parameters. Or you can pass a seed for the random number generated as a parameter to the constructor. Once you have a Random object, just call the nextInt method and you get a number between 0 and n-1 (n is the parameter you pass nextInt).

Now I had my number guessing program working in no time. I decided to add a little spice to the program that was not required. No I don't have Guess jeans models popping up on the screen. I just let the user keep guessing until they arrive at the solution. And I throw in some taunts as responses when you guess is wrong. Good stuff.

Java App Version One

It is about time for me to get down to business and code a prototype for my app ideas. Previously I had thought I needed a polished product. But version 1 does not need all that. It just needs to get done. Then I will try it out for myself and see what to change in version 2.

Of course I am going to use Java as the programming language. The eventual product will be a web app displayed in HTML. However the first version might even just be text based. We shall see. I will probably post a link to my alpha version when it is ready for distribution.

SonarJ Architecture Review

We have a relatively new developer on our project. He is a seasoned application developer. So you know he gets down into the trenches of our source code. It is funny how he is disturbed about how many things were done wrong in our system. Many of us know about these problems. But we are too busy or too worried about breaking things to fix them.

There is a new version of a solution called SonarJ that could assist with our problems. It analyzes code and detects your application architectures, and identifies things you have done wrong. You can get a clear view of how bad things are with their metric dashboard.

SonarJ goes even further by projecting the impact of refactoring your code. It does this without disrupting your code baseline. The tool can grab code from your IDE or your build project. And if it was not clear from the name, the tool targets code written in the Java programming language.

Event Based

Java has always used event based programming to deal with user interfaces. Initially would generate events and send them to components. The component would information the system whether it processed the event. If so, that was the end of the processing. Otherwise the system would forward the event to another component, and so on until one did process the event.

By the time Java 1.1 was released, event processing had changed. A new delegation model was adopted which implements the observer pattern. Any components interested in an event implement a listener interface. They register with the system to handle the event. This makes the system's job easier. When the event fires, all listeners registered for that event get notified. More than one component can receive and process the event.

If your component's event processing is going to take any real time, you should do the work in a separate worker thread to keep the system responsive for the user.

Abstract Window Toolkit

I have read an intro chapter on the Abstract Window Toolkit (AWT). It is implemented via the "java.awt" package. The package provides a number of graphic user interface components. Examples are buttons, scrollbars, and checkboxes.

Two of the most useful components are the TextField and TextArea. The TextField is a single line of input from the user, while the TextArea is a multiple line edit control.

Checkboxes are components. They can be grouped using a CheckboxGroup class, which itself is not a component.

A LayoutManager interface has been defined to determine how components are placed on a screen. There are 5 different implementations of the LayoutManager provided to you by the AWT.

Let's talk about a few more AWT concepts. A container is an area on the screen which holds other components. A windows is a top level one on the screen that has no menu bar or border. It is used to create popup messages. If the user provides input in a such a window, it is then called a dialog. A frame, on the other hand, is a window that has a title, border, and buttons like maximize/minimize.

The last idea which I shall expound upon later is that of events. The entire AWT system is driven by events. AWT manages these events, and sends them to interested components. For example, an event is generated when the user clicks the mouse button. The AWT catches this, and sends the information to component(s) that had previously requested mouse press events.

Origins of Java

A Java game programming book uses the Abstract Window Toolkit. So I thought I would read up on it a bit. There are some free materials online that cover this older technology. I figure what I learn can also help in my learning of newer GUI frameworks.

The book I read online claims that the AWT is crucial for Java programmers to learn. Initially there were major changes in AWT before it stabilized. Here is a funny thing. Part of the AWT intro explained the origins of the word Java.

Java is actually an island in Indonesia. It is not just any island. A whopping 124 million people live on the island. That is more than half the population of Indonesia. The capital of Java is Jakarta. This explains the naming for the Apache Jakarta project.

Next time I will get into some of the components that the AWT has to offer.

Accessing an Oracle Database

I am using JDBC to access an Oracle database using a Java program. To get up and running quick, I grabbed some code off the web. After importing java.sql.*, the thing compiled fine. However when I ran my program, I got some exceptions.

The first exception was that the class "oracle.jdbc.driver.OracleDriver" was not found. Ooops. Then I found out that this class had been deprecated. Fine. I replaced it with "oracle.jdbc.OracleDriver". That also generated an exception. There was also exceptions when I tried to make a database connection. The were due to there not being a driver. I figured that I needed to solve the root problem before proceeding.

There were a number of web pages that said I needed the JDBC driver installed on my system. I grabbed the "ojdbc14.jar" file and stuck it in a number of lib folders on my machine. No luck. I thought it might be due to the fact that I had a later version of the JRE and JDK. Turns out I needed the jar file in my classpath. Once I did that, the program worked fine. Now I am inserting a lot of database in my database. Maybe later I will post some code snippets.

JDBC Drivers

I am using the JDBC technology to access an Oracle database from a Java program. This technology requires you to use one of its drivers to do the access. There are different categories of drivers you can use to access Oracle.

One driver category is a thin driver. It has its own version of SQL*Net. In other words, you do not also need an Oracle client installed on your machine in addition to the driver. This category of driver is written in the Java programming language itself. There is also an OCI category or driver, that uses Oracle's Oracle Call Interface (OCI). The final category is a KPRB driver used for writing stored procedures and triggers in Java.

Besides the categories of drivers, there are also different levels of drivers. The first type is a bridge, where JDBC makes use of ODBC installed on your machine. ODBC is a generic database access technology. Other types are differentiated by whether the drivers themselves are written in Java, and how the SQL code is translated and sent to the database.

JDBC Data Access

I have been talking about this new project I am working on. There are a lot of URLs that I want to scrape. The first task is to put the list into a database. I have decided to use JDBC to access the database from my Java program.

Java Standard Edition 6 comes with the "java.sql" package. You should import all the classes in that package. JDBC requires a driver to run. You load the driver in your code with a Class.forName.

Any SQL can be sent to the database using JDBC. By default, the objects used to connect to the database automatically commit after each statement. You should use the close method on the connection object to free database resources.

Scanner Comes Through

I have a new project I am hacking on. The goal is to process a huge file of URLs. Then I want to crawl those web sites and extract information to a database. I will provide some more specifics in the future.

The first task at hand was to deal with this huge file. It was 10 gigabytes large. Most text editors could not handle it. I wanted to see if my Java classes could deal with it. So I coded up a UNIX head program. It lists of the first 10 lines from the file.

Bamm. It worked. The Scanner class could read the first 10 lines with ease. The first time it did so there was a small pause. But I could read and process the first 10 lines. It seems to reason I can process the next 10 lines, and so on.

I will keep you posted on the progress of my little project. Next step is to figure out how to do database access with Java. I am thinking JDBC. But there may be better or more interesting technologies to try out.

Window Pane Management

I have been creating buttons that have no text on them. They only have a graphic icon loaded from an image file. I noticed that the button size grows to accommodate larger pictures. This leads to different sized buttons and a messy user interface. There must be a way to keep a uniform button size, shrinking icon images as needed.

Another problem I have is when a control such as a button is invisible. The other controls rearrange during the paint() so as to obscure the position where the invisible control would be. I don't like this reshuffling of the screen when a control goes invisible. There should be a way to reserve space on the screen for a control that may become visible in the future. However this is not the default behavior.

I normally use appletViewer to test out my applets in development. But I found out that this tool only displays the embedded applet in an HTML page. It does not render any of the other HTML elements. Weird.

Button Action Command

Normally you have your applet listen for actions from your controls like the buttons in your applet. The event handler gets the action command. That command is normally the text on the button itself.

Recently I have been creating buttons that have no text. They just display an image that I loaded as the icon of the button. How does the applet know which control generated the event?

It turns out that you can call setActionCommand and pass it a String. This String is when the applet will get when it tries to get the command. It puts you back in control for the event processing.

Here is a tip I discovered the hard way. Make sure you addActionListener(this) on the button you want to handle events for. Otherwise the applet will never get a notification that your button was clicked. This might be obvious. But it is painful to debug when you forget to make the call.

Applets and Web Pages

So far I have been concentrating on applets. The applet is normally the entire web page. The HTML for the web page is merely to name the applet, and give it a size. However this is not normal. You usually have some other presentation in the HTML page. Therefore I did a more realistic project that integrated applet output with the markup from the HTML source.

I had an exercise from my textbook dealing with times. In Java, you can get the number of milliseconds since 1970. This feature has been encapsulated with the Date class. The default constructor of Date initializes the object to the current date and time. Use DateFormat to choose how you want to show the date. Even though the class is abstract, you can still call the static members.

What Time is it?

Here are some leftover tips from a textbook project I did recently. The format() function is a static one from the String class. It helps your output look good. Call it like this: String.format(...).

You can hide controls in an applet by using the setVisible function, passing in the parameter false. Here is something weird though. Hidden controls are removed from the user interface layout. There is no reserved space on the screen where the hidden control is supposed to be. The output looks as if the control was never there. Other controls will be placed over top of the region where the hidden control belongs.

Applets and Browsers

Sometimes I need to see how my applet looks in a browser. My browser of choice is Internet Explorer 6. Yes I know this is an ancient version. I tried installing version 8 but had some problems.

My IE6 blocks the applet from running by default on a web page. This is probably related to my security settings, and not my specific browser. I still need to click to "allow blocked content" before the browser will run my applet.

I am starting to see a pattern with applet GUI programming. Create a label, text field, and button. Add them all to the content pane. Then you make sure the applet can get the events from the button. This is all happening in my init() function. It is almost boilerplate code for me now.
Like most things, I find that writing the code for an applet is easiest if you start out with a working applet to modify. Now let's get back to some Java basics. Previously I had recalled how to convert a String to an int. Now I needed to do the same for a double. The tried and true design worked well.

You create a Double object. Pass the String into the constructor of the Double. Then you can assign the value of the Double to a double variable. The conversion works well. Actually I think this is implicitly calling a member of Double that returns a double. Is this what they call boxing? Or maybe it is unboxing.

Button Behavior

You size an applet in the HTML page that hosts it. I find that you need to size the applet area carefully to allows your controls to be layed out as expected on the screen.

The general pattern I use when user input drives the display is to have a member variable of my JApplet derived class. There is conditional logic in the paint() method that depends on this variable. When a user action changes the variable state, repaint() is called to redraw the screen.

I've been doing a lot with buttons that have no text on them. They only have an icon image on them. I have encountered some problems with transparency. I would like the button background color to bleed through any white portion of my image. However does not seem to be the default behavior of the button class. Maybe I need to set some unknown options. I hope I do not need to code or draw my own button face.

The JTextArea

I started using the JTextArea control in my applets. Seems all the good controls are in the "javax.swing" package. You pass in the height to the JTextArea constructor. However it seems that the thing will allow more than that many rows in the control. The control seems only bounded by the applet window size. What the heck?

You use newlines in the JTextArea text to make the thing jump to the next row in the control. One thing is strange though. The default behavior does not seem to provide anything other than the text in the control. There is no border or scrollbar or anything. Maybe there is some other control that is more like the Windows control I am used to.

Eclipse User Trends

Let's briefly look at the trends of Eclipse users. You could say they are comparable to the general Java development community. For starters they are using Subversion as the configuration management tool of choice. They also are using the Linux operating system for desktop development. These developers continually download and use the latest version of Eclipse.

CVS use is on the decline for configuration management. ANT is the build tools of choice. Maven is trying to catch up. Some are just using Eclipse itself to control builds. Web development is done using jQuery (I just got a book on jQuery, so I will be sharing what I learn). The majority of Eclipse users do not contribute to open source. That last statistic surprises me.

I hope I can get my hands on some survey data for Java developers as a whole.

Wish Upon a Star

I am moving on to writing more applets. These are simple programs to get my bearings. The most important methods in JApplet are init() and paint(). You add items or objects to the screen in the init() function. And you draw things such as labels and buttons in the paint() function.

If you handle some GUI events like button clicks, the pattern is to call repaint() to get the screen updated based on the user input. It is funny how quickly I forget my Java basics when I do not code for a long time. These rules have not been committed to heart.

For example, I had to rediscover how to convert a String to an int. You create an Integer object, passing the String into the constructor. Then you can assign the resulting Integer to a variable of type int. Also you need to qualify Math package functions with "Math." to get your Java to compile.

Some topics are universal. Break down complex routines into multiple subroutines (functions). Make use of constants instead of magic numbers. In Java this is done with public static final variables. I will say I am starting to get some bearings on how to do drawing on the Canvas. The upper left hand corner of the screen has coordinates (0,0). Increasing x goes to the right. Increasing y goes down.

My First Applet

Here I am in my full week of training. This is an independent study for me. My goal is to learn applet programing. Read a couple chapters in my school textbook. We always skipped the applet and other GUI sections. Unfortunately the applet chapter requires you to read the big Java Swing chapter. I have skipped it. So I am going to be having some troubles.

Applets do not have a main function. Instead they have an init. They close when the web page that contains them closes. The containing web page is written in HTML. The applet itself runs on the client machine. There are some security restrictions like an applet cannot run a program, read a file, or write a file. You should test your applets on many browsers including multiple versions of the same browser.

The older class for applets is Applet. Go figure. You cannot use Swing with this old style class. You also cannot do icons or menus. Use buttons instead. I found that I could load an HTML page which referenced an applet. However when I recoded and recompiled the applet, an Internet Explorer 6 refresh would not run the new version of the applet. That was annoying. Instead I decided to use appletviewer. Here is another strange thing. The reload function in appletviewer causes the window to disappear and the viewer to freeze. Another funny thing was that I tried to use Graphics2D in my paint method. It compiled but just output a light blue screen. All my graphics were gone. I guess I can make do with the normal Graphics class.

Applet Time

In my college Java class, we skipped over most of the information on applets. I wanted to learn more about them though. There was a whole chapter in the text that covered applets. I also have a lot of information on my latest book about applets for game programming in Java.

It is time for me to learn applets. I convinced my employer to let me spend a week in independent study on Java. I need some program to keep me busy to really learn practical applet programming. Initially I thought I would write a copy of an arcade classic such as Pacman. However I think I will need more than a week to get deep into applet programming.

My new plan is to actually try to duplicate the main program we have on our project at work. It is a client/server C++ Windows application that connects to an Oracle database. This might be a good sized program to implement as an applet. The thing is over 2o0k lines of code. This will keep me busy for quite some time. I figure I can work on it in the office, and not get too much attention on my sideline activities.

Access Modifiers

Just read a rant about a developer that likes to use parentheses to make the order of operations explicit. He does not want a reader of his code to need to know the operator precedence rules. As an extension, he also explicitly declares the access modifier for any java function that he writes.

This started a big discussion on what it means to not specify an access modifier for a Java function. In C++ it is easy. C++ class members without an access modifier are private. C++ structure members without an access modifier are public. However in Java, not specifying an access modifier means the function is package private.

Package private has no keyword. It is the access allowed when you do not specify a modifier. This causes the function to only be accessible by other members in the package. This is different than public, private, or protected. I am sure I learned this some time ago in my Java college class. However today it was solidified.

Web Frameworks

I found this free e-book which describes some web development frameworks for Java developers. These frameworks are like those of event driven GUI applications. However they sometimes have steep learning curves. Java provides some web technology. But it does not provide a web application framework. So these third party frameworks have come about to help you with the low level tasks.

Struts is the most well known framework. It is well documented and has a large following. A drawback of using struts are the big configuration files. You need to use a lot of XML markup files for forms and rendering. I hear that developers are moving away from this framework in general.

Java Server Faces (JSF) is another framework. It runs on an application server like WebSphere. It strives to decouple the components and the view. The most frequently used implementation of JSF is Apache's MyFaces. JSF uses a managed bean to store user info. The bean classes contains the logic. This technology is backed by big companies like the former Sun Microsystems. A few years back I did hear that JSF might not be appropriate for mission critical applications. Not sure whether this opinion has since changed yet.

Game Programming

I just started reading The Black Art of Java Game Programming. And I tell you what. I already have a good feeling about this book. Sure it was written in 1996 when Java 1 just came out. However by chapter 2 we are already learning about animation. Damn.

One thing that struck me as odd was that the authors of the book are young. Or more precisely they are still in school. One of these is an undergrad, and the other a grad. That does not mean they are junior. They seemed to be on the cutting edge of Java right when it came out.

This book does specialize in teaching you how to code network games. The authors believe that object oriented programming is the way to go for creating games. They are going to teach me a lot about AWT (since Swing has not been invented I guess).

Chapter 1 already got me into a lot of Java syntax. It also highly recommends you use arrays instead of lists for speed. Back in 1996, Java ran a lot slower than compiled C or C++. I also learned some basic stuff I was never taught in my Java college class. The import statement allows you to reference classes in packages. However you can still access those classes without an import by using the classes fully qualified name. I did not know that. I am excited about getting into the meat of this book. Who knows? I might be turning out some cool games in no time.

Java Enterprise Edition 6

I read an article on the good things coming in Java EE version 6. There is a new API for REST. There is a web profile, meaning you can use a scaled down version of the previously bloated enterprise edition. In the tools department, there is a new version of NetBeans being released.

Enterprise Java Beans has been updated. Things have gotten much simpler with it. The beans are "light". Complexities such as requirements for frameworks are gone. This is in line with the scaled down profile version of the Java EE.

Right now I am still concentrating on learning Java Standard Edition. Some Java friends keep asking me whether I am up to speed on Java EE. It might be time to start learning it. Looks like I will have access to a new updated version, which is actually simpler than previous ones.

Java Game Programming

I read a blog post about hiring for startups (or something like that). It was written very well. So I checked out the author's bio. Turns out he was one of the authors of an old book called The Black Art of Java Game Programming. When I say old, I mean it was published in the 1990's for Java 1.0.

Normally books like these get obsolete immediately. And this book seems to have code that became obsolete with Java 1.1. However a number of comments on Amazon indicate the book still has a lot of merits. Well it warrants a read by me even though the book might be 25 years old. I placed an order with Amazon today.

I will let you know what I learn. Things are looking good for my Java development. I took a college class last year. This year I plan to take a week off from work and complete the remaining chapter in my college class textbook. I had though I might learn some more HTML programming (including JavaScript) later this year. However I might change direction and get deeper into Java. If so you will be hearing about it with some more frequent posts on this blog. Stay tuned.

Java Running on Apple II c

I just heard that a subset of Java can now run on the Apple IIc computer. Bamm. Of course there are some limitations. You need a real Apple II c with the 65C02 microprocessor. That means Apple II e computers don't work with this port.

The good news is that some of Swing is available. No AWT or JDBC is supported yet. The eventual goal is to port all of Java to the Apple. Right now there is also a JDistro available. This is a desktop which is written in Java Swing. JDistro is a limited version too that can only run 1 app at a time.

The whole thing fits on 3 floppies. Source code will be made public. This seems pretty hard core as the Apple II is some hardware from yesteryear. Now we just need Java ported to the Tandy Coco III, and I will be complete.

Making the JVM Fast

Java was a very slow performer when it first came out. Then it started becoming a contender for other compiled languages like C and C++. In fact, Java is faster than C++ in some cases. But in general it is a little slower.

All code is interpreted by the Java Virtual Machine. However for methods that are used very frequently, the JVM compiles the code and then you get really good performance. The trick is that the JVM can see how the code is used many times. Then it has the knowledge needed to optimize the compilation.

With the default options, code written in smaller sized methods runs faster. The reason for this is the the JVM will not compile methods that are too large. You can modify this behavior with some options. In fact you can even force the JVM to compile everything. While this might seem to be best, it is not. You should let the JVM interpret the code first. Only after interpreting a method many times can it make the best optimizations for compilation.

J2EE to Tomcat Port

There is a movement in the enterprise to port J2EE applications to lightweight Java containers such as Tomcat. This is part of the Agile development movement. There are many ways to tackle this port. You can just code some services up in lightweight Java. Or you could just write the new stuff in lightweight Java.

Techniques such as SOA are complex. Java frameworks now offer a lot, but have a small code footprint. There are multiple lightweight Java containers. Tomcat from Apache happens to be a free and popular one. This may be the way of the future. Developers are tired of running under app servers like WebSphere.

Servoy Library

Servoy Corporation is releasing its libraries under a GPL license. They provide access to Java function within JavaScript. The solution uses native Java code. You can think of this as JavaScript wrapping Java objects.

This solution is aimed at web developers. Servoy will release the source code on their own hosted Subversion servers. The GPL license requires that users of their libraries in turn make their source code available to the public free of charge.

Mission Critical Java Apps

Department of Defense standard DO-178C defines methods to verify object oriented systems for critical uses. In the past, Java has not been normally used for mission critical applications. All that may be changing now.

Java now has JSR-302 which addressed safety critical Java. Safety critical apps are mostly the domain of large scale DoD sponsored programs with big money backing them. This is a good move for the Java world.

Java on the Cloud

A bunch of companies are working on a Java based solution to cloud computing. It will be using the Spring framework. It will run on vSphere from VMware. And it will be hosted on the servers. This beat will be called VMforce. I guess that means that VMware is the main company behind it.

This solution will be able to host any Java application in the cloud. There are around 6 million Java developers out there. Cloud computing is supposed to boost their productivity. So if this works, this may have a big impact on their productivity. Look for VMforce to be available later this year.

Java Performance

In the old days, there was much concern that Java programs were slow and could not complete with C or C++ programs. It seems that this is not as true any more. I just read a huge discussion on the topic. Here are some interesting points I came out with.

C has a small footprint. So if that is required, choose C. Java has a long startup time. This is the time it takes for the JVM to load and initialize. We are talking on the order of seconds here.

Direct machine access can be done with Java using JNI. However it is clunky. In C, direct machine access is natural. However garbage collection in Java is easier than C's malloc/free. Java also make parallel programming easier.

Be careful when you are comparing speed between Java and C programs. You must ensure both programs are using the same algorithm. You also need accurate stats to make a good comparison. As an aside, C# will normally be a little bit slower than Java.

Java 7

Java 7 is big. The Java Virtual Machine will support dynamic languages. Strings can be used in a switch statement. The JVM performance has been improved. A new garbage collector called the G1 is the source of the speed up.

There are other niche additions to Java in Java 7. For example, in the security world, there will be support for curve cryptography. Personally I care little about JVM support for dynamic languages. Java with its static typing is fine for me.

Gosling is Gone

James Gosling, creator of Java, has quit from Oracle. He announced this on his blog. Strangely enough, his blog has disappeared. I guess they chop your blog at Oracle when you leave.

Gosling did not provide a reason for leaving. Hello? Can you say Oracle acquisition? He is going to take some time off.

Word on the street is that the Java faithful were taken by surprise. Does this mean that Gosling will not be present at JavaOne? You got to go and find out.

Oracle Plans

Oracle Corporation has a number of plans for the future of Java. They plan to merge the HotSpot and JRockit JVMs into one product next year. They also will be supporting languages other than Java in the JVM. These will include Ruby and Python.

There is also talk that the Java SE and Java ME platforms will merge into one. Perhaps that means that mobile apps are becoming common. It is either that or mobile apps are not as important any more.

The JavaOne conference is going to be held in tandem with the OpenWorld conference. You can register and attend events at both conferences. JavaOne will now be held in the September time frame. I guess Oracle has decided what has the precedence. At least they are not ending JavaOne.

Object Database

I saw an advertisement while perusing a technical magazine. It was for an object database created by InterSystems. The product was called Cache. What caught my eye was the claim that it had technology to persist Java objects with a relational mapper.

The object model for Cache is based on the Object Database Management Group (ODMG) standards. It works with C++ and .NET as well as Java. The marketing boasts 5x the speed of normal relational databases.

Cache is meant for Rich Internet Application development. It uses an application server. However there are multiple ways to make use of the object database. You can use templated classes. There are also lightweight API calls for direct database access. Finally there is the Jalapeno technology.

Jalapeno stands for JAva LAnguage PErsistence with NO mapping. You create your Plain Old Java Objects (POJO) first. Then you use Cache to generate a schema to work with those objects. Cache has a library class to deal with the database. You can apparently just focus on your POJOs, and Cache will do the rest like magic.

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.