Java and Perl information for statisticians
FPL Statistics Unit
Java and HTML forms/Perl information for statisticians
The following information was compiled for
a poster session presented at the August 1997 American Statistical
Association annual meetings. It is based on the experiences of a
statistician who has developed both Java and HTML forms/Perl/FORTRAN
programs for the Web.
On 4/10/03 I checked the links and removed invalid ones, but by now
my experience is out of date (although I still produce Java programs).
However, for the time being I am leaving this up as it might represent a starting point
for someone who is interested in producing Web-based programs.
Please note that these sites are not endorsed by the Forest
Service.
Java
Before I give you my list of resources, let me refer you to
a very useful Java site: William Wagers'
Focus on Java at http://java.about.com.
Also take a look at Java World and the associated links.
Also, here is Chapter 1 -- "What is Java?" -- from Peter van der Linden's
Just Java 1.1 and Beyond, 3rd Edition.
Resources
- Books that I own: (4/10/03 --- These were good books in their
day, and the newest versions of them are still probably good, but I
haven't checked in the last three years.)
- Teach Yourself Java 2 in 21 Days, Lemay and Cadenhead,
Sams.net Publishing. Good first Java book.
- Core Java 2, Cornell and Horstmann, SunSoft
Press/Prentice-Hall. Good second Java book. Two volumes.
- Graphic Java 2 , David Geary, Sunsoft
Press/Prentice Hall. Includes David Geary's Graphic Java Toolkit
which extends the AWT. I've used his rubberbanding material. Two volumes.
- Java in a Nutshell, 2nd Edition, David Flanagan, O'Reilly.
Reference.
- Book lists/reviews:
- Java News:
- Java Community (clubs, forums, mailing lists, news, newsgroups, Java blogs, ...):
- Newsgroups:
- William Wagers' list of Java FAQ's ---
http://java.about.com/cs/jfaqs/index.htm
- User Groups:
- Statisticians doing Java work (big time outdated as of 4/10/03): http://www1.fpl.fs.fed.us/devel.html.
Let me know if you would like to
be placed on this list.
- Java programming sites:
- Java and statistics/mathematics sites: (I also recommend going to Google and doing a
search on Java and the mathematical item in which you are interested.
There are lots of web lists of mathematical routines written in Java.)
- Java Integrated Development Environments (IDEs):
My Java development work:
- http://www1.fpl.fs.fed.us/linear_algebra.html
--- Numerical linear algebra.
This package contains unofficial Java versions of many of the
BLAS (Basic Linear Algebra Subroutines), and the LINPACK
Cholesky decomposition (dpofa, dposl, and dpodi), QR decomposition
(dqrdc and drqsl), singular
value decomposition routines (dsvdc), and LU decomposition (dgefa,
dgesl, and dgedi) routines.
- http://www1.fpl.fs.fed.us/optimization.html
--- Nonlinear optimization.
This package contains unofficial Java versions of the 1-dimensional
minimization routine fmin, the multi-dimensional minimization
routine UNCMIN, the
MINPACK nonlinear least squares routines, and a SLATEC 1-d
zero-finding routine.
-
http://www1.fpl.fs.fed.us/distributions.html ---
Evaluating certain statistical cumulative distribution functions and
their inverses.
-
http://www1.fpl.fs.fed.us/quadrature.html ---
Quadrature (numerical integration).
-
http://www1.fpl.fs.fed.us/covnorm.code.html ---
Java code to calculate exact
confidence bounds on a normal distribution coefficient of
variation.
- http://www1.fpl.fs.fed.us/manyreg.html
--- Interactive regressions. This material consists of the beginnings
of seven packages (in the Java sense): corejava (written by Cornell
and Horstmann for their book, Core Java), rubberband (written by David
Geary for his book, Graphic Java), distributions, regression,
sorts, SPV_graphics, and tests_of_fit. It demonstrates:
- Application --- reading from and writing to the local disk
- Applet --- reading from and writing to the server
- double buffering to reduce flicker
- rubberbanding
- panels, canvases, buttons, text fields
- frames that are independent of the browser
- mouse driven events
- (somewhat primitive) x-y plots
- exception handling
- packages
- javadoc
- http://www1.fpl.fs.fed.us/mfa0.html ---
an example of interactive nonlinear regressions
Miscellaneous tips / suggestions / common errors (big time out of
date as of 4/10/03)
- Newbie stuff:
- Case (lower and upper) is significant.
- You cannot have a comment delimited by /* and */
inside another such comment.
- File name must match public class name.
- When you're doing "java name" to run "name.class" don't do
"java name.class" or "java name.java".
- If you are working on Windows 95, use the full names of
files, not the DOS versions.
- Local variables must be given values before they are used.
(There are no default values.) The
compiler will complain otherwise. This is not true for instance and
class variables.
- If you have an old version of a class lurking about somewhere in
the CLASSPATH, you can make changes in a file that will be masked
by the old version if it appears earlier in the CLASSPATH.
- If you have a class file in a directory in your CLASSPATH and
that file has the same name as a class file downloaded by your browser
as part of an applet, your local class file is used.
This can be the source of seemingly
inexplicable behavior when you are developing on two machines and
checking the applet on both, and the class files versions are not
completely in sync.
- Slightly more advanced stuff:
- To the extent possible follow the coding style conventions
described in Doug Lea's draft Java coding (style) standard ---
http://g.oswego.edu/dl/html/javaCodingStd.html.
- Use javadoc.
- Use packages.
- Use exceptions.
- Remember that primitive types (e.g., integers, doubles, ...)
are passed by value rather than by
reference. This is important if you are translating a FORTRAN program
that passes, say, a real variable by reference. In the FORTRAN
program the variable might be modified in a subroutine. In this case
the value that you get back after the call will be modified. In Java
this will not be the case. If you want pass by reference behavior,
you will need to embed the primitive type in an object (e.g., an
array).
- The Random class in java.util is supposed to be a better random
number generator than Math.random.
- In 1.0.2, there is a compiler bug that places a limit on the
number of local variables (see
http://java.sun.com/products/jdk/1.0.2/KnownBugs.html#Compiler).
The claim is that this limit is 63, but I believe that I've run into
trouble with a smaller number of local variables. This can present
a problem to someone who is translating code from FORTRAN to Java.
HTML forms / Common Gateway Interface (CGI) / Perl
Resources
- Books that I own:
- Teach Yourself Perl Programming in 21 Days, Till, Sams
Publishing. You really
can teach yourself lots of Perl in 21 days. The new edition is
titled
Teach Yourself Perl 5 in 21 Days.
- Programming Perl, Wall and Schwartz, O'Reilly and
Associates.
- Teach Yourself Web Publishing with HTML 3.0 in a Week,
Lemay, Sams.net Publishing.
- Build a Web Site, net.Genesis and Hall, Prima Publishing.
This book is "old" (1995), but it is probably still quite useful. It
covers, among other topics,
setting up a Web server, HTML, and details of CGI programmming
via Perl.
- Teach Yourself CGI Programming in a Week, Colburn,
Sams.net Publishing. This is a relatively recent book (copyright
1998) and it at least mentions some of the newer technologies. This
book is a useful supplement to the books mentioned above.
- Book lists/reviews:
- Some WWW sites:
- Newsgroups:
Examples of HTML form --> Perl --> FORTRAN --> HTML
Tips for HTML form --> Perl --> FORTRAN --> HTML
- If you
- understand the back-end programming language (e.g., FORTRAN,
C, ...),
- have a limited understanding of Perl,
- have access to Perl templates such as those provided in the
examples or in the last two books listed above,
- have a basic understanding of HTML (it's also useful to
understand how to produce tables in HTML), and
- have access to HTML forms templates such as those provided in the
examples or in the last three books listed above,
then you can produce forms-based WWW programs.
- I needed the statement
$| = 1; in my Perl programs
to avoid problems with mixing Perl and FORTRAN output.
- The Perl
system(@proglist); command
sends information to the FORTRAN program and executes the FORTRAN
program. The first element in @proglist is the name of
the FORTRAN program that will be executed. The remaining elements are
the arguments that will be passed to the FORTRAN program. These
arguments are fed into the FORTRAN program by statements such as these:
character*80 argv,intwrite
call getarg(1,argv)
write(intwrite,7) argv
7 format(a80)
read(intwrite,*) sg0
These statements read the second element in the @proglist
(the first is the name of the FORTRAN program) into the variable sg0.
For further information, please contact Steve Verrill at
sverrill@fs.fed.us or 608-231-9375.
[Forest Service]
[Forest Products
Lab]
[FPL Statistics Unit]
Last modified on 5/29/03.
As of last midnight, this page had been accessed




times.