java2html 1.3.1

by Lorenzo Bettini

This is a simple program that, given a source java file, produces an html
source with syntax highlighting.

As it is a GPL program, I provide sources (~70k), but if you don't fell like
compiling it, you can download Win32 executable (~270k) (new).

Java2html is a GNU program, so you can download it also fro GNU's ftp site:
ftp://ftp.gnu.org/gnu/java2html/

Otherwise you can download sources or executable directly from my home
pages:
http://w3.newnet.it/bettini/software/java2html/java2html-1.3.1.tar.gz
http://w3.newnet.it/bettini/software/java2html/java2html-1.3.1-exe-Win32.zip
(win32 executable)
or if you're in Italian University (GARR), here's some faster places:
http://infostud.dsi.unifi.it/~bettini/software/java2html/java2html-1.3.1.tar.gz

http://infostud.dsi.unifi.it/~bettini/software/java2html/java2html-1.3.1-exe-Win32.zip
(win32 executable)

or you can get the pacthes (see below for patching from a previous version):

   * java2html-1.3-1.3.1.patch.gz

Changes from v. 1.3

   * fixed a bug with \\ inside strings and chars (notified by Ziv Caspi
     <zivc@peach-networks.com>)

Changes from v. 1.2

   * it should compile under gcc 2.95 (there was a problem with const char *
     solved by Luc Maisonobe <Luc.Maisonobe@cnes.fr>)
   * a bug with \", \' and & was fixed (Jari Korva <jari.korva@iki.fi>)
   * test added to make (run make test to have some Hello*.html files)
   * java2html can now produce a .css format(thanx to Jari Korva
     <jari.korva@iki.fi>) and also some .css files are included (some by
     Jari and some by Kaloian Doganov <kaloian@stones.com>).

Changes from v. 1.1

   * compiled version with Cygnus Win compiler and tools: Cygwin tools
     http://www.cygnus.com/ (should run fine under WinNT as well, please try
     :-)
   * a bug with single quotation fixed
   * -input, -output, -title (thanks to Robert J. Clark <clark@klgroup.com>)
     and -verbose options added
   * syntax has slightly changed

Changes from v. 1.0

   * A bug with // comments has been fixed.
   * tags.j2h is now included in win32 zip file
   * tab option added (to substitute tab with a number of spaces)
   * automake applied to the distribution (this means you have also make
     install option and other GNU programs standard (wonderful) features :-)

Installation

See the file INSTALL for building and installation instructions (if you're
used to compiling Linux software you may guess it: configure && make && make
install). java2html has been developed under Linux, using gcc (C++), and
bison (yacc) and flex (lex), and ported under Win32 with Cygnus C/C++
compiler, available at http://www.cygnus.com/ (a .DLL is also distributed
togheter with the .exe: you may simply copy it in the same place of the
.exe).

Patching from a previous version

If you download a pacth, say java2html-1.3-1.3.1-patch.gz (i.e. the pacth to
go from version 1.3 to version 1.3.1), cd to the directory with sources from
the previous version (java2html-1.3) and type:

gunzip -cd ../java2html-1.3-1.3.1.patch.gz | patch -p1

and recompile the whole thing (if you had already run configure a simple
make will do).

Usage

java2html only does a lexical analisys of the source code, so the Java
program is assumed to be correct !

here's how to run it:

java2html -input <file (a java prog)> -output <file (an html)>

if you want a real html document, specify -doc option at the end. Otherwise
you just get some text to copy and paste in you own html pages. If you
choose -doc option the page will have a white background and your source
file name as title. -tab=n option apply a substitution of tab characters
with n spaces. You also may want to specify the title of the page with
-title "my title" option (this implies -doc). Now you can also generate an
html with CSS format, by using -css "url of .css" (try some .css files
included in the package). The order of the options is not relevant.

Use Hello.java to make some test, if you want. Here's how Hello1.html,
Hello2.html, Hello3.html, Hello4.html, Hello5.html were created:

java2html -input Hello.java -output Hello1.html
java2html -input Hello.java -output Hello2.html -doc
java2html -input Hello.java -output Hello3.html -title "Happy Java with java2html :-)" -tab=3
java2html < Hello.java > Hello4.html -title "and what about CSS :-)" -css "Hello.css"
java2html < Hello.java > Hello5.html -title "Wooo... this is quite dark ;-D" -css "mono-alt.css"

which can also be obtained by typing

make test

This test works if you type it after the installation or if you have . in
your PATH.

And here's the output of `java2html -help`

Syntax : java2html [-input infile] [-output outfile] [-doc] [-css [<cssurl>]] [-tab=#] [-title "Document Title"]
  -doc   : create a complete html doc (with <HTML>, <BODY>...
  -tab=# : substitute a tab char with # spaces
  -css : Use CSS instead of font-tags in output
         <cssurl> is the URl for the CSS document
  -title "Title of HTML Document" :
           Text to use for the title of the HTML document (-doc forced).
  -verbose : verbose execution
  If -input is not specified, stdin is assumed
  If -output is not specified, stdout is assumed

As it handles standard output and input you may also run it like

cat MyFile.java | java2html | lpr

You may want to specify your options for syntax highlighting in the file
tags.j2h. If this file is not present in the current directory some default
colors will be used. Here's the tags.j2h file that comes with this
distribution:

keyword blue u ;
type green ;
string red ;
comment brown i ;
number purple ;

as you might see the syntax of this file is quite straightforward:
b = bold, i = italics, u = underline.
You may also specify more than on of these options separated by commas
e.g.
keyword blue u, b ;

you may see all possible colors in the file colors.html

if something goes wrong with your options try to run java2html with -verbose
option enabled

Credits

Many people sent me much feedback and some of them also sent some patches
for bug fixes and new features :-)
Here they are (if I forgot someone please mail me):

   * Marcus G. Daniels <marcusd@gnu.org> who gave me some good advices about
     GNU standards,
   * Osvaldo Pinali Doederlein <osvaldo@visionnaire.com.br> for tab option
     idea,
   * Richard Freedman <rich_freedman@chiinc.com> for feed back and bugs
     signalations
   * John Constantine <John.Constantine@mail.cc.trincoll.edu> for some great
     suggestions I'll surely apply.
   * Raymond Lambe <rlambe@morgan.ucs.mun.ca>, for quotation bug signalation
   * Robert J. Clark <clark@klgroup.com> for adding -input, -output, -title
     options
   * Hans-Peter Bischof <hpb@cs.rit.edu> for suggestions (to apply).
   * Luc Maisonobe <Luc.Maisonobe@cnes.fr> for the patch for const char * in
     order to make it work under gcc 2.95
   * Jari Korva <jari.korva@iki.fi> for the bug of \" inside a string and &
     treatme nt, and especially for adding CSS options and handling
   * Kaloian Doganov <kaloian@stones.com> for .css suggestion and for
     providing some nice .css files
   * Ziv Caspi <zivc@peach-networks.com> found the bug of \\ in chars

See also mails.txt :-)

Feedback

Tell me if you like this software :-)

Actually I want to extend it, so if you have some ideas...
The most import one will be to make java2html more customizable :-)

Please send all bug reports by electronic mail to:
bug-java2html@gnu.org

My home page is
http://w3.newnet.it/bettini  or
http://infostud.dsi.unifi.it/~bettini (very fast if you're in University)

java2html is free software. See the file COPYING for copying conditions.
Anyway I won't get offended if you send me a postcard :-)

  ------------------------------------------------------------------------

Return to GNU's home page.

Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are also
other ways to contact the FSF.

Please send comments on these web pages to webmasters@www.gnu.org, send
other questions to gnu@gnu.org.

Copyright (C) 1999 Free Software Foundation, Inc., 59 Temple Place - Suite
330, Boston, MA 02111, USA

Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved.

 Updated: 27 Mar 1999 jonas
  ------------------------------------------------------------------------
