Tuesday, January 13, 2009

A close look at the NetBeans output

My intention at this point was to visit the lesson on running jar package software, but NetBeans, after building the app, suggested running it with the following command:

java -jar ActiveMathJA002.jar

I think I'll try that first, as I have a command window open and all the files are in the right place.

Well the command worked OK, and my app opened, but it didn't work properly. Months have passed since I drafted the code, but it seemed as if an early version was running. Why would it work one way when run from within NetBeans and another when run as a stand-alone?

I commented earlier that I was surprised to see draft versions included in the NetBeans built jar file. I think I'll take the drafts out. While I'm at it I'll check the dates of the main class files.

The date on the class files extracted from the jar file is Aug 31 2008. That seems wrong, because I ran the build command yesterday. Checking out the build folder, there are two class files with slightly more recent dates (September 2 2008). I'll use them and rerun the command to build the jar file with the specified entry point and see what happens.

Now it's looking for

which I assumed was an early draft. So I'll add that back to the folder I'm using for my manual build. Now the app runs pretty much as it does from NetBeans. There is some stuff being written to standard output which I thought I'd commented out, but besides that the basic execution path seems to be the same.

A number of questions arise from all of this:

  • Why don't the built file dates match the last time I ran the build command?
  • Why is has the jar file an earlier date than the class files?
  • Why are three class files needed for the main class?
  • Why was the entry point not included in the manifest?

It turns out that the answer to all of but one of these questions was that for some reason I was running NetBeans from a backup drive, and therefore running the tests on the wrong files. When I looked closely at the correct jar file, everything was as it should be. The main class still seemed to made up of three files, but apart from that everything was fine.

No comments: