This is a simple program that, given a source java file, produces an html source with syntax highlighting.
Java2html is free software. Please see the file COPYING for details. For documentation, please read this file. As it is a GPL program, I provide sources (~70k), but if you don't fell like compiling it, you can download Win32 executable (~100k) ().
Java2html is a GNU program, so you
can download it also fro GNU's ftp site:
or from here:
Java2html main home page is at GNU site:
You can also get the pacthes from the GNU ftp site (see below for patching from a previous version).
cd <source code main directory> ./configure make make installNote: unless you specify a different install directory by --prefix option of configure (e.g. ./configure --prefix=<your home>), you must be root to 'make install'.
Files will be installed in the following directories:
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). I used the excellent GNU Autoconf and Automake. I also used Autotools (ftp://ftp.ugcs.caltech.edu/pub/elef/autotools) which creates a starting source tree (according to GNU standards) with autoconf, automake starting files. Finally I used GNU gengetopt (http://www.gnu.org/software/gengetopt), for command line parsing.
Actually, unless you want to develop java2html, you don't need all these tools to build java2html because I provide generated sources; you don't need neither bison (yacc) nor flex (lex), for the same reason. Actually programs that use lex generated files need to link with library libfl (or libl for lex); anyway configuration phase can discover if this library is missing and in that case it sets the program to link with a source file I provide. This hack works for flex: I don't know about lex generated scanners. But, again, this is a problem only if you develop java2html and you use lex.
gunzip -cd ../java2html-1.3-1.3.1.patch.gz | patch -p1and restart the compilation process (if you had already run configure a simple make will do).
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. You may also want to customize the produced document: you can use --header and --footer options that allow you to specify files to be included, respectively, at the beginning and at the end of the document.
Use Hello.java to make some test, if you want. Here's how Hello1.html, Hello2.html, Hello3.html, Hello4.html, Hello5.html, Hello_h_f.html were created:
java2html -i Hello.java -o Hello1.html java2html --input Hello.java --output Hello2.html --doc java2html -i Hello.java -o 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" java2html --doc *.java Processed Hello.java (creates Hello.java.html) java2html --doc -i Hello.java -o Hello_h_f.html --header="header.html" --footer="footer.html"which can also be obtained by typing
make checkAnd here's the output of `java2html -help`
Usage: java2html [OPTION]... [INPUT-FILE]... java2html < INPUT-FILE > OUTPUT-FILE [OPTION]... given a source java file, produces an html source with syntax highlighting. -v, --verbose verbose mode on -d, --doc creates html with title, header... -c, --css=URL use a css for formatting (implies --doc) -T, --title=TITLE give title to the html (implies --doc) -i, --input=FILE input file (default standard input) -o, --output=FILE output file (default standard output) -t, --tab=TABLEN specify tab length (default 8) -H, --header=STRING file to insert as header -F, --footer=STRING file to insert as footer -V, --version print versionAs it handles standard output and input you may also run it like
cat MyFile.java | java2html | lprYou 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 b ; type green ; string red ; comment brown i ; number purple ;as you might see the syntax of this file is quite straightforward:
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
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:
|See also cpp2html http://www.gnu.org/software/cpp2html/cpp2html.html.|
My home page is
http://infostud.dsi.unifi.it/~bettini (very fast if you're in University)
and this is my e-mail address where you can contact me about java2html, or other things
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 firstname.lastname@example.org. There are also other ways to contact the FSF.
Please send comments on these web pages to email@example.com, send other questions to firstname.lastname@example.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