Posts

Showing posts from January, 2009

Elements of the JNLP File

In my last blog I attempted to run an applet using the following jnlp file:: <?xml version="1.0" encoding="utf-8"?> <!-- JNLP File for ActiveMath --> <jnlp spec="1.0+" codebase="http://202.65.70.207/myweb/" href="AMJ002.jnlp"> <information> <title>Active Math Java Test</title> <vendor>Softway Interactive Education</vendor> <description>Active Math Java Test</description> <homepage href="http://202.65.70.207/myweb/index.htm"/> <description kind="short">ClickMeApp uses 1 custom class plus 1 standard one</description> <offline-allowed/>> </information> <resources> <jar href="ActiveMathJA002.jar"/> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> </resources> <application-desc main-class="AMJFormA002"/> </jnlp> The er

Testing the JNLP File

In my last blog I attempted to reverse engineer the notepad example and ended up with the following text: <?xml version="1.0" encoding="utf-8"?> <!-- JNLP File for ActiveMath --> <jnlp spec="1.0+" codebase="http://202.65.70.207/myweb/" href="AMJ002.jnlp"> <information> <title>Active Math Java Test</title> <vendor>Softway Interactive Education</vendor> <description>Active Math Java Test</description> <homepage href="http://202.65.70.207/myweb/index.htm"/> <description kind="short">ClickMeApp uses 1 custom class plus 1 standard one</description> <offline-allowed/>> </information> <resources> <jar href="ActiveMathJA002.jar"/> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> </resources> <application-desc main-class=&quo

Creating the JNLP File

This lesson is a subsection of the Deploying Java Web Start Applications lesson begun 2 blogs ago, and it continues to be as brilliantly written. It begins with an example. Examples are nice, but in most teaching traditions they are used to illustrate lessons already learnt from first principles. Sometimes they are posted early in a lesson to stimulate thought, and then referred back to as the the lesson unfolds to explain the principles applied in the example. In this case, there is actually no lesson, before or after the example. Instead there is simply a list of elements and attributes. It reminds me of the user manual for MS BasicA, which was published in 1982. I thought user documentation had progressed since then, but obviously not here. It is hard to believe this is the same tutorial which used a screen shot to explain how to save a text file . Now we are left to reverse engineer a fiddly piece of code, with lots of redundant or superfluous tags, and translate it

The joys of Microsoft IIS

I had a problem installing IIS and as it was asking for the XP SP3 CD, I downloaded SP3, slipstreamed with my existing XP install files, and burnt a new bootable CD. And I hardly need record that IIS still wouldn't bloody well install. An illustration of the nightmare is given in this thread on the MS Community forum. Check out the tizzy some of the participants get into. The solution for me was given in the penultimate post in this long thread and it may be reached with this link . Of course I had forgotten how set folder security through IIS, and I hadn't a clue which port was being used. The answers were provided for me in this thread in the MS forum (whatever faults MS may have, and despite the large egos of the some of its users, the forum is an excellent resource). I duly copied my web to inetpub (in a subfolder called myweb), allowed anonymous access, allowed access through port 80 in the Windows firewall, and mapped port 80 to the appropriate pc in

Setting up a Web Server

In the context of the Java Tutorial as a whole, the topic of Applets is a major section in the Deployment trail. It is preceded by another largish section Java Web Start . This promises "to launch full-featured applications with a single click". At this stage all I want to do is to launch my mini app with a single click, so I really don't want to get bogged with detail here. But I am not optimistic. The second paragraph refers to a JNLP file, whatever that is. My hopes of a "quick" start are fading. It looks as if there is a lot to work through. And if you follow the thread in order, the first lesson, Running Java Web Start Applications , is interesting from the perspective of trying out the technology, but from my perspective useless right now, because it assumes the JNLP file already exists. The second lesson, Deploying Java Web Start Applications , looks more hopeful but it contains a number of potentially quite tricky steps. And in the less

Running JAR-Packaged Software

In The Java Tutorial, the lesson on running jar package software opens by introducing three scenarios: Your JAR file contains an applet that is to be run inside a browser. Your JAR file contains an application that is to be invoked from the command line. Your JAR file contains code that you want to use as an extension. The second of these I have already covered, I have no idea what the third means, so I shall focus on the first. I shall create an experimental page on my web site to test the line by line. From the example given: "open brace" applet code="TicTacToe.class" archive="applets/TicTacToe.jar" width="120" height="120" "close brace" I shall post: "open brace: applet code="AMJFormA002.class" archive="ActiveMathJA002.jar" "close brace" I have removed the height and width parameters because they don't apply to my app. When I refresh my page I get a brief flash of the jav

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 s

Setting an Application's Entry Point

In the Java Tutorial, this lesson begins with the example: Main-Class: MyPackage.MyClass Notwithstanding all the work on packages in recent blogs, I'm still working with the jar file made from the version without a custom package assigned. But according to a recent post on the beginners' forum, if the class is in the default package, this line reads: Main-Class: MyClass Which in my case will be: Main-Class: AMJFormA002 I have saved this line (with a carriage return at the end) in a file called entry.txt. Now I have to run the generic command jar cfm MyJar.jar Manifest.txt MyPackage/*.class Which in my case translates as: jar cfm ActiveMathJA002.jar entry.txt *.class Before doing this I note the the current jar file has the date Aug 31 08 (how time flies). There's a pause but no error messages when I run it. And sure enough the jar file date has changes. I'll just file away the expanded contents and run the extract command again to see what's in th

Checking the NetBeans jar file

I've noticed in the fora that when people using IDE tools run into difficulties there is a chorus from the crowd that they should learn to do it all manually before working with fancy tools. I have also noticed that NetBeans has produced a so-called executable jar file for me, but before trying to run it, I'll use the lessons to check out a few details. First I'm just going to try out the code in the Viewing the Contents of a JAR File lesson to check the content of the jar file. The output is as follows: META-INF/ META-INF/MANIFEST.MF AMJFormA002$1.class AMJFormA002$2.class AMJFormA002.class AMJQGenA002.class I am curious that the jar file seems to include two early drafts of the main class. That's not a problem now (the file is still only 10kb) but it could become an issue in the future. Besides that everything seems to be there. A manifest seems to have been included although I am not sure what it says. I'll now apply a code scrap from the

Packages and packages

My first instinct when I had created an applet, with a beginning, a middle and an end, was to deploy it - to make it run outside the NetBeans IDE. I needed to revisit packaging not least because the first lesson in the Deployment Trail is entitled Packaging Programs in JAR Files (my italics). What induced Sun to use such confusing nomenclature? It was only after spending hours pouring over every word in the Packaging trail, that I realised that the two concepts are wholly unrelated. The term package in the context of classes and interfaces refers to an implicitly defined collection of source code files. Belonging to a "package" is an attribute of a source code file, given in the first line of code. The term package when used in the Java tutorial in the context of deployment has the more common (in my opinion) meaning of bundle of files, or archive, like a zip or rar file. And the file extension of the package even sounds like rar. It is in fact jar

Re-using code

So now I have an applet which works (and works jolly well, though I say so myself), but the code has been assigned to the wrong package, and I'd like to start again, with everything assigned to an appropriate package, but I don't want to fiddle around with the graphics on the JFrame getting all the shapes sizes and fonts right again. So I want to reassign the classes I've already created to the right package. Coming from a Microsoft background, I think in terms of exporting files to a package, and I look in the file menu for something resembling export or import. There is something for project groups, but nothing about assigning files to packages or importing or exporting. Next I look in tools. Maybe there is a package assignation tool? No luck there. Options? I am clutching at straws now. So I scan through every menu, and find nothing. Maybe if I right click on the class file icon there will be a context menu item about assigning the class to a pac

Applying the lesson

After completing the introductory trail Learning Swing with the NetBeans IDE , I decided to apply the lesson by building an applet of my own. Like the Celsius converter, the applet included a text box, a label, and a button, but it also needed something more. Whereas the Celsius converter takes input from the user and processes it to produce a directly related output, I wanted my applet to generate some output of its own, and then respond to the user's response to the initial output. At this point I ask: Am I alone. The answer is definitely not, because people have been doing what I am doing since computers were invented. But am I in a minority of Java users? I guess if I think of the majority of forms on the web, they certainly kick off with mainly empty test boxes, and then they respond to what is written in the text boxes, initially with the application of a business rules layer, and then perhaps by writing to a database or generating a message for someone. My

NetBeans IDE Basics

This lesson talks you through NetBeans IDE application interface. This is worth a read. My first impression, having forked out several hundred dollars for VB5 and the same again for later editions, was to be amazed at the sophistication of the application. I was quite excited about the prospect of using it. The next lesson, Creating the Celsius Converter GUI , takes you step by step through the process of adding components to the JFrame (or form, as I still like to think of it). It's not rocket science, but it's nicely explained, and from my perspective as an ex-VB user, I was pleased to see the instructions pretty much as I expected them to be. This is followed by Adjusting the Celsius Converter GUI , which fine tunes the components. Again there is nothing too frightening here, but I couldn't help concurring with the lesson comment: "...you might be surprised at the amount of code that has been generated ...". The word bloat came into my mi