Showing posts with label applet. Show all posts
Showing posts with label applet. Show all posts

Deployment Options

I got a new idea for a computer program I want to write. First I need to walk the thing all the way through to completion. I need users to be able to run this program on their own machines. I am thinking about using Java for the coding, but want to ensure a smooth user experience.

To run the Java bytecode on their machines, the users will need the Java Runtime Environment. What if they do not have it on their machine? Or what if they have the wrong version? I need my software to work the very first time, and every time after that.

I did some research on the subject. I can package up my files as a jar. However this still requires the JRE to be installed. Or I could go the web way and use Java Web Start. That would require me to set up a web server to host the apps. Then they will get downloaded to the user machine. That might require too much infrastructure for me.

I could also distribute the program as an applet. Then the whole thing runs in the browser. This also requires some infrastructure. But it will just be a web page. I do not have a lot of experience with applets using Java. That is a consideration.

Finally there are some compilers that produce executables that run directly on the user's native machine. This is the next best thing to developing with a language like C++ and compiling a version for the target machine. I need to play with ohe of these programs that produces a stand alone Java executable before I make a final decision.

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.

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

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.