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.