Java tips and programs

Here's a collection of java programs I have for folks to look at. They are all free to use.

Bolthole java software
Java Tutorial This is an incomplete work in progress, started Oct., 2012
Java App skeleton Rather than starting from scrtch, you can use this code to jumpstart your own java application
ErrDialog.java Dumb little window to alert the user to something, but go away after they click ok.
ChoicesDialog.java Fancier version of above. For when you need to prompt the user to make a choice Right Now.
Jcrossclient A java front end to Crossfire, the multi-user game (very old now, out of date!)
Jdrill A java program to help study Japanese Kanji
utfconvert A java program to convert charset encodings (eg: UTF->EUC)
Xpm.java An .xpm format reader for java
UserPrefs.java java class for loading user preferences in an application. Docs here
Listor A free table-like class, to list data in rows (click to see applet, and source code) AWT based. Allows user to resize column widths.
FscrollPane.java A free substitute for java.awt.ScrollPane
FscrollTable demo Better yet, an AWT table class! (rather bare bones, binary only)
About.java A trivial "About" box that can also be used to pop up any text file
jmail.java A trivial "send SMTP" prog that uses java's "Mailto" URL handling to send email. Works with any JVM since java 1.0, I think.
flexilayout A work-in-progress to give a very flexible layout widget. Allows you relative positioning to two other objects, for independant up/down, and x/y control. Does for FlowLayout what GridBagLayout does for GridLayout: Surpasses it in the extreme. Click through for the flexilayout home page.
jdbentry A GUI utility to let you or a user add rows by hand to a table in a local database. Currently geared for use with MySQL, but should be easy to modify for use with Sybase, Oracle, etc.
jhtmlindex A small java prog that takes a HTML page as STDIN, and spits out a simple table of contents, using OL tags.
  
javascript+pureHTML
co-existence
Okay, this is NOT JAVA! But I needed somewhere to link this from, so here it is.
This page demonstrates some methods for how to make a page that works great with both javascript-enabled browsers, AND plain non-javascript-enabled browsers.

Javasoft resources

Sadly, http://java.sun.com/applets/ is now defunct. The good news is, though, the old javasoft tutorial is still being maintained by oracle: http://java.sun.com/docs/books/tutorial/ still redirects to a valid place.

There are a LOT of resources there. It isn't always obvious, but if you dig deep enough in there, you can usually find the "best" way to do most things with java. But not AWT. AWT rocks, but is unappreciated. Note that the class tree for it, can be found hiding in places like http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/package-tree.html

To learn the basics of the java language, use the " Learning the Java Language" subpage.

Oreilly book on AWT

This looks like a book ad, but its actually a free way to read the book by downloading chapter PDFs: http://oreilly.com/openbook/javawt/book/index.html.

Unfortunately, the book is kind of wordy.


Treating classes as 'optional'

Sometimes, you'd like to use a new-and-spiffy class in the latest JDK, but you also want to allow your program to work on older java versions. A lot of folks think that they have to choose either the latest java runtime + features, OR the old runtime, when targetting what java platform to write for. Sometimes, however, you can do both!

If you are taking advantage of a new java class in later runtimes, that simply is not present in older runtimes, you can choose to enable o disable features depending on whether the new class is accessible. The following code shows how to do this.

Download and compile parent.java and aux.java, two simple classes. Run 'parent' to see it use the 'aux' class. Then remove the 'aux.class' compiled class, and run 'parent' again. It will run differently, because it detects that the aux class is not available.


General tips on how to use java as a user

First, you have to GET a java runtime!
As of 2013, the best way for developers seems to be to go to http://www.oracle.com/java


If you want to run Japanese-displaying java software

It used to be that if you wanted to display more than plain ASCII characters, you had to get a version that has the full "internationalization" support. Nowadays with broadband, they just distribute the full verison. However, you might have to tweak your java, unless you're on MacOS.

For details, see my Unicode setup pages, then come back here to finish up.


Using a java runtime

Okay, you have the runtime... now you want to run a program! For the older stuff, your setup is somewhat longer, for every program you want to run.

HISTORICAL INFORMATION ONLY

If you are using java made in the 21st century, this does not apply to you :) I just like leaving my old docs around for historical purposes. How to run progs with java 1.1

If you have a newer java 1.2-based runtime, you should be able to run most, if not all, of my programs "directly". That is to say, with a single click in a GUI environment. Some platforms require a little more setup than others, but once you are done, you should be able to run the ".jar" file just like it was any other program.

Read the java 1.2 details on how to set up one-click operation.


If you have any suggestions, comments, or "hey, it works on platform xyz, cool", drop me a line!
phil@bolthole.com

Bolthole.com