home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / DOC / HOWTO / OTHER_FO / SGML / JAVA_HOW.GZ / Java-HOWTO.sgml
Encoding:
SGML Document  |  1996-06-02  |  32.3 KB  |  826 lines

  1. <!-- This is the Java on Linux HOWTO, SGML source -- >
  2. <!-- Eric S. Raymond, esr@snark.thyrsus.com -- >
  3. <!-- The submission address is gregh@sunsite.unc.edu -- >
  4. <!-- Updates should also go to karl@ncm.com and chapman@u.washington.edu --> 
  5.  
  6. <!doctype linuxdoc system>
  7.  
  8. <article>
  9.  
  10. <title>Linux Java HOWTO
  11. <author>maintained by Eric S. Raymond,
  12. <htmlurl url="mailto:esr@snark.thyrsus.com" name="esr@snark.thyrsus.com"> 
  13. <date>v2.3, 29 May 1996
  14.  
  15. <abstract>
  16. This document describes how to get started with Java and HotJava under
  17. Linux, as either a user or a programmer.
  18. </abstract>
  19.  
  20. <toc>
  21.  
  22. <sect>Introduction
  23. <p>
  24. This document is a Linux-centric introduction to the world of Java and
  25. HotJava.  These technologies are rapidly evolving, and we welcome
  26. contributions from anywhere.
  27. <p>
  28. Places in this document that are in serious need of checking or filling out
  29. are bracketed with *** ***.  Also see the <ref id="needed" name="To Be
  30. Added..."> section below.  Please help us improve this HOWTO.  Send updates
  31. and change requests to 
  32. <htmlurl url="mailto:esr@snark.thyrsus.com" name="<esr@snark.thyrsus.com>">.
  33. </sect>
  34.  
  35. <sect> General Questions About Java and HotJava
  36. <p>
  37. This section is a general (non-Linux-specific) introduction to Java and 
  38. HotJava.
  39.  
  40. <sect1> What are are Java and HotJava and why are they interesting?
  41. <p>
  42. Java is a network-aware language superficially resembling C++, but much
  43. smaller and more compact and cleanly designed.  It's an unlimited-extent
  44. language with garbage collection like Lisp, but with static type checking
  45. (it's been aptly described as "Smalltalk with sane syntax").  It includes
  46. lightweight processes (threads) as a native facility and has powerful
  47. network-security features.  So far, its major application is the HotJava
  48. browser, but it holds considerable promise as a general-purpose application
  49. language.
  50.  
  51. HotJava is a WWW browser written in Java.  Its major advance over
  52. most other browsers is that it knows about a new HTML construct called an
  53. APPLET, which is some Java class that executes on the client machine.
  54. Thus, WWW documents written with Java in mind can have "live" code
  55. objects embedded in them, as opposed to just data.
  56.  
  57. The ability to safely pass around code objects probably represents the most
  58. significant advance in WWW technology since the first release of Mosaic.
  59. At minimum, it delivers an extensible Web browser that won't need
  60. perpetual upgrading to handle new image formats and tag types.
  61.  
  62. Java is compiled into a pseudo-code called `J-code'; Java interpeters
  63. execute J-code.  J-code may be on its way to becoming a universal
  64. architecture-independent virtual machine-code or compiler intermediate
  65. language.  We hear rumors that an ADA-95 compiler that generates J-code has
  66. already been built and that a C compiler is in progress; eventually, it's
  67. likely that multiple front-end languages will be available for writing
  68. either applets or standalone programs on any machine hosting a Java
  69. interpreter.
  70. </sect1>
  71.  
  72. <sect1> Where do Java and HotJava come from?  Who can use them?
  73. <p>
  74. Java and HotJava were developed at Sun Microsystems by a team headed 
  75. by James Gosling (well known as the designer of Gosling Emacs and
  76. NeWS).
  77.  
  78. The last time Sun tried to set a major technical standard was NeWS,
  79. its Network Window System.  Though NeWS was pretty universally
  80. conceded to be technically superior to X, X won because its sources
  81. were freely redistributable.  Sun learned from this mistake, and has
  82. made Java/HotJava much more generally available; the sources can be
  83. downloaded under a fairly relaxed license (see <ref id="license"
  84. name="Java as Freely Redistributable Software">).  Sun is
  85. encouraging ports to non-Sun environments.
  86.  
  87. Netscape now interprets Java.  Microsoft licensed the technology in
  88. early December 1995.  So it appears that Java support will probably
  89. become universal in 1996.
  90.  
  91. Java used to be called Oak.  HotJava was once known as WebRunner.
  92. </sect1>
  93.  
  94. <sect1> How mature is Java?
  95. <p>
  96. On December 12 1995 Sun released the `Beta 2' version of Java.  A month
  97. later it released 1.0, the first `production' version.  The Java
  98. environment API defining its access to the host OS and windowing system has
  99. allegedly been semi-frozen -- it may be extended, but won't be incompatibly
  100. changed.
  101.  
  102. The 1.0 version of this FAQ was issued along with the beta 1.0 
  103. Java Developer's Kit (JDK) for Linux, ported by Randy Chapman.
  104.  
  105. Significant holes are known to exist in the Java security
  106. implementation.  It is not yet a good idea to use Java for sensitive
  107. applications.  These problems are expected to be fixed in the production
  108. (post-beta) releases.
  109. </sect1>
  110.  
  111. <sect1> Where can I find documentation on Java and HotJava?
  112. <p>
  113. Sun maintains an extensive HTML web of Java and HotJava-related
  114. documents at <url url="http://java.sun.com">.  These documents are 
  115. mirrored at <url url="http://java.blackdown.org"> and elsewhere; see
  116. Sun's list of mirror sites.
  117. </sect1>
  118.  
  119. <sect1>Yes, but where can I find paper documentation?
  120. <p>
  121. SunSoft Press's official series of Java books is in the production pipeline at
  122. Addison-Wesley.  Some details about these can be found in the
  123. <url url="http://www.city-net.com/~krom/java-faq.html"
  124. name="comp.lang.java FAQ">.
  125.  
  126. Several Java early-adopters have recommended "Hooked on Java" by the
  127. members of the Java team.  "Well written, though I'd appreciate something
  128. less basic" was one comment.
  129.  
  130. O'Reilly Associates is working on its own series of Java books in
  131. cooperation with Sun.  Your humble editor is the primary technical reviewer
  132. for this series.  So far (as of May 1996), only the "Java In a Nutshell"
  133. guide has come out; it's pretty good. The series will include (at least) a
  134. language reference, a class library reference, and a book on the underlying
  135. byte-code virtual machine.
  136.  
  137. SAMS has a book called "Learning Java in 21 Days".  No review yet.
  138.  
  139. One of our contributors, browsing his local Bookstop/Barnes &
  140. Noble/Borders, came up with 3 books already out:
  141. <itemize>
  142.     <item>One called 'Java in 60 minutes' that looked like a pretty
  143.         strict syntactic description (about $20).
  144.     <item>One from SamsNet called just `Java' (about $20).
  145.     <item>One by Tim Ritchey called `Java!' that includes a
  146.         CD-ROM (about $35).
  147. </itemize>
  148. Our informant continues: "I bought the 3rd one (by Tim Ritchey). Paper
  149. leadtimes being what they are, the CD-ROM only has alpha stuff, though it
  150. mentions that the beta version might be out by the time you read it and
  151. suggests java.sun.com as a place to get more recent information.  Other
  152. than that, it's pretty good, even to pointing out that `well, it's
  153. pointless for me to spam you with pages and pages of API descriptions
  154. because 1) it would quadruple the size of the book and 20 they're still ch
  155. anging and 2) you can get that info online at ...etc'"
  156.  
  157. Dave Dittrich writes: I'd say that "Java in 60 minutes" may take you 60
  158. minutes to read, but won't teach you how to program in Java in 60 minutes
  159. (surprise, surprise!)  It looks to me like "Java in 60 minutes" is one of
  160. the many attempts be first to market with a book on a hot topic.  It didn't
  161. seem to include much more than you can find right now on the Web, including
  162. lots of text that looks like it was lifted straight out of the Java
  163. Language Specification (http://java.sun.com/JDK-beta2/psfiles/javaspec.ps).
  164.  
  165. Dave continues: Same thing with "Java!", only the latter goes into much
  166. more detail on object oriented programming concepts, etc.  Someone pointed
  167. me to another text book that is equally as good at covering data/method
  168. abstraction and other object oriented programming concepts, which is
  169. "Structure and Interpretation of Computer Programs" by Abelson, Sussman and
  170. Sussman (MIT Press).
  171.  
  172. Final caveat: at this point (January 1996), it is probly a good idea to
  173. stay away from the Ritchey book or anything else based on the alpha API.
  174. The beta API is substantially different, and the soon-to-be-released Java
  175. 1.0 will have its own differences.
  176. </sect1>
  177.  
  178. <sect1> Where can I find on-line collections of Java code?
  179. <p>
  180. WWW archives of applets are available at the following locations:
  181. <itemize>
  182.     <item><url url="http://java.sun.com/">
  183.     <item><url url="http://www.applets.com/">
  184.     <item><url url="http://www.gamelan.com/">
  185.     <item><url url="http://www.javasoft.com/applets/applets.html">
  186. </itemize>
  187. Most of the applets on these pages come with source code, and programmers
  188. are invited to use them.
  189.  
  190. Pointers to others may be available in the
  191. <url url="http://www.city-net.com/~krom/java-faq.html"
  192. name="comp.lang.java FAQ">.
  193. </sect1>
  194. </sect>
  195.  
  196. <sect> Java as Freely Redistributable Software <label id="license">
  197. <p>
  198. Many Linux programmers are attached to producing freely redistributable 
  199. software (FRS), and try to avoid committing a lot of time to tools for
  200. which sources are not generally available.  In this section, we discuss
  201. Sun's and Java's relationship with the FRS world.
  202.  
  203. (Warning: I am not a lawyer.  I am neither employed by, nor an agent of,
  204. nor a stockholder in, Sun Microsystems.  This section is based on my
  205. interpretation of the current copyright law and the Sun licensing language.
  206. Treat this as an introduction; the Sun licensing page, <url
  207. url="http://www.blackdown.org/Java/licensing.html"> is definitive. If you are
  208. in serious doubt about what it means, consult an attorney.)
  209.  
  210. <sect1> Are Java programs and applets freely redistributable?
  211. <p>
  212. They are if you write them and choose to make them FRS through some
  213. mechanism (such as the GPL, or a BSD-style license, or declaring them
  214. public domain).
  215.  
  216. <sect1> What can I do with Java implementation binaries?
  217. <p>
  218. The Sun licensing page has this to say:
  219. <quote>
  220. The unmodified Java and HotJava binary releases may be redistributed free
  221. of charge in both commercial and non-commercial applications.
  222. </quote>
  223. Also:
  224. <quote>
  225. Companies or individuals who wish to create a new port of the Java
  226. language have the right under this agreement to post the binaries
  227. of that port to the Internet for use by others, as long as the    
  228. port is free of charge and passes the publicly available test          
  229. suites. (Test suites will be available sometime in the first half      
  230. of 1996.) The "diffs" may also be posted on the web as long as the     
  231. underlying source code is not posted. The Java source code is          
  232. </quote>
  233. So if you've got a working Java or HotJava binary, you can give it to your
  234. buddies.  Or put it on a CD-ROM.  Or do anything except patch it and
  235. represent the patched version as Java.  (This is reasonable.  Sun obviously
  236. can't leave itself without recourse against Trojan horses sailing under the
  237. Java banner.)  Binaries are FRS.
  238. </sect1>
  239.  
  240. <sect1> Which parts of the Java sources are freely redistributable?
  241. <p>
  242. According to Sun's licensing page, none of it is.  But that sounds harsher
  243. than it is.  In practice, anyone can get the Java and HotJava sources for
  244. educational, porting, and non-commercial purposes by filling out a Web form
  245. which obligates them not to redistribute the sources.  And the agreement
  246. <em/does/ permit redistribution of diffs against the sources.
  247.  
  248. The only circumstance that requires you to sign a commercial license with
  249. Sun and pay them money is if you want to use the sources in a commercial
  250. product.  In particular, the way the language is written, it's within the
  251. letter and spirit of the agreement for you to sign Sun's noncommercial
  252. source license, snarf the source, port it, and give away the resulting
  253. binaries as completely unencumbered freeware!
  254.  
  255. Sun says that its primary purpose in keeping as much control as it has
  256. is to keep the language from mutating into incompatible dialects.  The
  257. license language supports this; it seems to have been designed to allow
  258. hackers to play for free.
  259. </sect1>
  260.  
  261. <sect1> What is Sun's attitude towards FRS Java implementations and tools?
  262. <p>
  263. The Sun licensing page says:
  264. <quote>
  265. The specifications for the Java Language and the Java Virtual Machine are
  266. OPEN and are copyrighted by Sun Microsystems, Inc.
  267. </quote>
  268. <quote>
  269. Reimplementations of the Java Compiler or the Java Runtime Interpreter
  270. are permitted without requiring a license from Sun provided such      
  271. implementations are created directly from the published specifications     
  272. and without the direct or indirect use of Sun's own implementations or     
  273. other intellectual property rights, including trademarks.                  
  274. </quote>
  275. So if you want to go to the effort of creating a Java clone from the
  276. published specifications that is FRS, Sun won't stop you.
  277. <p>
  278. Sun people use the term "rogue port" for Java implementations that either
  279. (a) are performed outside Sun, or (b) don't rely on Sun-licensed code
  280. (sometimes the term seems to mean one thing, sometimes the other).  They
  281. seem to think some of these already exist, but we don't know where they
  282. are, nor if they are FRS.  They're pretty relaxed about the situation.
  283. <p>
  284. Sun has a Java validation suite.  They have said they'll certify any Java
  285. port that passes it.  (Whether this validation will cost money is unknown,
  286. but Sun says in writing that the suite wil be "publicly available" in 1996,
  287. which at least hints that it will not.) They're prepared to certify rogue
  288. ports, though this apparently hasn't happened yet.
  289. </sect1>
  290.  
  291. <sect1> Is anyone cloning Java in freely redistributable source?
  292. <p>
  293. There is a clone of the Java compiler in early development.  It's
  294. called guavac.  You can find more information at
  295. <url url="http://http.cs.berkeley.edu/~engberg/guavac">
  296.  
  297. There is a free runtime Java system called Kaffe. You can find more
  298. information at 
  299. <url url="http://web.soi.city.ac.uk/homes/tim/kaffe/kaffe.html">.  There's
  300. a FAQ at <url url="http://web.soi.city.ac.uk/homes/tim/kaffe/faq.html">.
  301.  
  302. There was a rumor afloat that Cygnus Software's GROW project has plans for
  303. a Java byte code interpreter to be issued under GPL.  This is false; what
  304. they are working on is a Java-to-native-code compiler that doesn't go through
  305. J-code.  You can get more information on related efforts at <url
  306. url="http://webhackers.cygnus.com/webhackers/projects/java.html">.
  307.  
  308. Per Bothner of Cygnus has written free replacements (more-or-less) for
  309. javah and javap. (See ftp.cygnus.com:pub/bothner/gjava*.tar.gz.)
  310.  
  311. Erik Troan of Red Hat and your humble editor are attempting to put together
  312. a development group to do the rest of the job.  Right now it looks like
  313. we'll use guavac as the compiler, Erik will do the class library and your
  314. humble editor will do the byte-code interpreter (if Cygnus hasn't gotten
  315. there first).  This project was tentatively named "Mr. Coffee" but is now
  316. called JOLT (Java Open Library & Tools).
  317.  
  318. <sect1> Are there any FRS Java Tools?
  319. <p>
  320. There is a GNU Emacs mode for editing Java.  You can fetch it from
  321. <url url="ftp://java.sun.com/pub/java/contrib/emacs">.  Note: this
  322. mode assumes you're using c++-mode.el, and won't work with the cc-mode.el
  323. distributed with Emacs 19.
  324. </sect1>
  325. </sect>
  326.  
  327. <sect> Java On Linux Questions
  328. <p>
  329. Here you can learn the nuts and bolts of getting Java running on your Linux.
  330.  
  331. <sect1> Are Java and HotJava included in any of the Linux distributions?
  332. <p>
  333. No, not yet, but expect it any week now.
  334. </sect1>
  335.  
  336. <sect1> How can I get the latest Java distribution for Linux?
  337. <p>
  338. Look in <url url="http://www.blackdown.org/java-linux.html">.  There
  339. is a list of mirror sites you can download it from.
  340.  
  341. The files you'll need are
  342. linux.jdk-1.0-try1.common.tar.gz
  343. and one of either 
  344. linux.jdk-1.0-try3.static-motif-bin.tar.gz
  345. or
  346. linux.jdk-1.0-try3.shared-motif-bin.tar.gz,
  347. depending on whether you have Motif shared libraries on your system.
  348.  
  349. If you have Red Hat Linux or some other system that speaks RPM, you can
  350. install the 1.0 beta from
  351. <url url="ftp://java.blackdown.org//pub/Linux/RPMS/i386/JDK-linux-common-1.0b-1.i386.rpm">
  352. and
  353. <url url="ftp://java.blackdown.org//pub/Linux/RPMS/i386/JDK-linux-static-1.0b-1.i386.rpm">
  354. or
  355. <url url="ftp://java.blackdown.org//pub/Linux/RPMS/i386/JDK-linux-shared-1.0b-1.i386.rpm">.
  356.  
  357. For European users, the contents of ftp://java.blackdown.org/pub/Java/linux
  358. and ftp://java.blackdown.org/pub/Linux/RPMS/i386/JDK-linux* are now
  359. mirrored in the UK in <url url="ftp://ftp.linux.org.uk/pub/linux/java">.
  360. That's zen.btc.uwe.ac.uk, in case anyone cares.  Mirroring happens daily at
  361. about 6am UK time.
  362.  
  363. This port (from the Sun sources by Randy Chapman) is the one that's referred to
  364. (as the JDK) elsewhere in this HOWTO.
  365. </sect1>
  366.  
  367. <sect1> What environment will I need to run Java?
  368. <p>
  369. For starters, you need an ELF-based Linux.  There is no a.out support,
  370. and at the speed the Linux world is switching over to ELF there is not
  371. likely to be any in the future.
  372. <p>
  373. You need a 1.2.13 or later kernel.  Kernels 1.2.12 and older seem to have a
  374. bug in getcwd(3) that tanks bin/javac because it doesn't check the
  375. getcwd(3) return code.
  376. <p>
  377. You'll need these pieces:
  378.  
  379. <itemize>
  380.     <item>libc.so.5 => /lib/libc.so.5.2.18 &nl
  381.         (The standard C library)
  382.  
  383.     <item>libX11.so.6 => /usr/X11/lib/libX11.so.6.0 &nl
  384.         (The base X11R6 library)
  385.  
  386.     <item>libXt.so.6 => /usr/X11/lib/libXt.so.6.0 &nl
  387.         (The Athena toolkit library)
  388.  
  389.     <item>libXext.so.6 => /usr/X11/lib/libXext.so.6.0 &nl
  390.         (The X extensions library)
  391.  
  392.     <item>libXpm.so.4 => /usr/X11/lib/libXpm.so.4.3  &nl
  393.         (The X library for pixmap handling.)
  394.  
  395.     <item>libdl.so.1 => /lib/libdl.so.1.7.9 &nl
  396.         (Linux dynamic-loader support)
  397. </itemize>
  398. The C and X support libraries may be in your Linux already.
  399. <p>
  400. If you don't already have it, get libc.5.2.18.bin.tar.gz from
  401. <url url="ftp://tsx-11.mit.edu/pub/linux/packages/GCC/">.
  402. Uncompress and untar and copy the files in the lib subdirectory
  403. of the top level of the hierarchy to /lib.
  404.  
  405. If you don't have a current version of ld.so (or libdl.so.1.7.*) you
  406. will need to update. ld.so.1.7.9 and .11 will work; .10 and other early
  407. versions will not. Get ld-so.1.7.14.tar.gz from
  408. <url url="ftp://ftp.ods.com/pub/linux/">;
  409. Uncompress and untar it and run <em/instldso.sh/ which is
  410. in the top level of the resulting hierarchy.
  411.  
  412. You can get an Xpm library that will work from 
  413. <url url="ftp://sunsite.unc.edu/pub/Linux/libs/X/libXpm.3.4f-ELF.tar.gz">.
  414. </sect1>
  415.  
  416. <sect1> Do I need Netscape?  Can I use Netscape?
  417. <p>
  418. Yes, you need Netscape.  HotJava isn't yet available for the beta pr 1.0
  419. releases.  Randy Chapman says:
  420. <quote>
  421. Sun massively changed the awt interface when they shipped the
  422. beta JDK and have not yet converted HotJava to it.  They have promised
  423. they will, and it should work great with linux-jdk when they release it.
  424. </quote>
  425. It's unknown when this will happen.
  426. <p>
  427. Netscape versions starting from 2.0b3 are Java-aware.  It is available at
  428. ftp[1-7].netscape.com (i.e. at ftp1.netscape.com,
  429. ftp2.netscape.com,... etc.)  Version 2.0b4 and up will allow you to read
  430. applets from file: URLs, 2.0b3 didn't.  This should be a big help for folks
  431. with small-memory machines (they don't need an httpd running).
  432.  
  433. Note that Netscape will run on an a.out system, so it is, in theory,
  434. possible to write your java app, give it to someone else to compile (like
  435. maybe the <url url="http://mars.blackstar.com" name="BlackStar Public
  436. Compiler">), and see the output on your system.  If you want more than
  437. that, get an ELF system.
  438.  
  439. Make sure CLASSPATH is <em/not/ set before running netscape; having
  440. it set seems to crash Netscape, and if you follow the directions below it
  441. won't need tweaking.
  442.  
  443. The Linux Netscape port has a few known problems.  It doesn't do sound.
  444. Only 8-bit displays work; 16bpp displays yield crashes.  The 2.0b3 version
  445. occasionally yields bus errors when caling the dispose method for frames.
  446. While it's pretty robust otherwise, Gamelan's `Impressionism' applet is
  447. known to crash it.
  448. </sect1>
  449.  
  450. <sect1> What mailing lists or newsgroups exist for supporting Java on Linux?
  451. <p>
  452. <itemize>
  453. <item><em/java-linux/ (Maintained by karl@blackdown.org)
  454.         Discussions and developments concerning the port of Java to the
  455.         Linux operating system. Email to
  456.     <htmlurl url="mailto:java-linux-request@java.blackdown.org"
  457.         name="java-linux-request@java.blackdown.org">
  458.     with the word `subscribe' in the subject to be added to the list.
  459. <item><em/java-linux-announce/ (Maintained by karl@blackdown.org)             
  460.     Moderated list for announcements concerning the Java-Linux           
  461.     porting projects. Please send e-mail to
  462.     <htmlurl url="mailto:java-linux-announce-request@java.blackdown.org"
  463.         name="java-linux-announce-request@java.blackdown.org">
  464.     with the word subscribe in the subject, to be added to the list.
  465. <item><htmlurl url="news:comp.lang.java" name="comp.lang.java">
  466.     Newsgroup for general Java discussion.
  467. <item><htmlurl url="news:alt.www.hotjava" name="alt.www.hotjava">
  468.     Newsgroup for discussion of the HotJava browser.
  469. </itemize>
  470. </sect1>
  471. </sect>
  472.  
  473. <sect> Building the Linux Java port on stock Linuxes
  474. <p>
  475. In this section, we collect recipes sent to us for building Randy Chapman's
  476. Java port on various current Linux distributions:
  477.  
  478. <sect1> Slackware distribution ELF kernel 1.2.13.
  479. <p>
  480. John Franks <john@math.nwu.edu> writes that he succeeded with the
  481. following steps: 
  482.  
  483. <itemize>
  484.     <item>Get linux-x86.jdk.static-motif.tar.gz from 
  485.         <url url="ftp://www.blackdown.org/pub/Java/linux/">
  486.         and uncompress it and untar it.  (The filenames you must fetch
  487.         have changes for the 1.0 beta JDK.)
  488.  
  489.     <item>Get libc.5.2.18.bin.tar.gz (binary distribution, not source) from
  490.         <url url="ftp://tsx-11.mit.edu/pub/linux/packages/GCC/">
  491.         Uncompress and untar and copy the files in the lib subdirectory
  492.         of the top level of the hierarchy to /lib.  Make sure
  493.         that /lib/libc.so.5 is a symlink to this file.
  494.  
  495.     <item>Get ld-so.1.7.14.tar.gz from ftp://ftp.ods.com/linux/
  496.         Uncompress and untar it and run "instldso.sh" which is
  497.         in the top level of the resulting hierarchy.
  498. </itemize>
  499. You should now be able to compile and try the "hello world" program
  500. and applet from Sun following the instructions at <url
  501. url="http://java.sun.com/progGuide/index.html">.
  502. </sect1>
  503.  
  504. <sect1> RedHat 2.1/Caldera Preview 2
  505. <p>
  506. Steve Greene <sgreene@access.digex.net> reports success doing
  507. the following steps.  I have edited the recipe slightly, so blame any
  508. mistakes on me.  The `JDK' he refers to is the Chapman port of the
  509. Java Developer's Kit.
  510.  
  511. <itemize>
  512.     <item>From a Red Hat mirror site, get the rpm available for 
  513.         ld.so.1.7.14.  To find it, check any RedHat mirror site for:
  514.  
  515.         /pub/mirrors/redhat-2.1/updates/RPMS/ld.so-1.7.14-i386.rpm
  516.  
  517.         I know it is available at ftp.pht.com, ftp.caldera.com. and is 
  518.         probably at the other RedHat mirrors as well.  Grab it, and
  519.         do `rpm -Uvh ld.so-1.7.14-1.i386.rpm' on your system.
  520.  
  521.     <item>Red Hat 2.0 and Caldera Preview 2 users may need the `which' 
  522.         program (it's called by some of the scripts in the JDK). 
  523.         An rpm file for `which' is available at the usual Red Hat
  524.         mirror sites as part of the Red Hat 2.1 distribution files.
  525.         Get and install which-1.0.i386.rpm.  RedHat 2.1 users
  526.         should already have which on their system or available
  527.         within their original distribution.
  528.  
  529.     <item> Get the tar file(s) for the statically-linked JDK.
  530.         Untar it from a convenient point.  I put mine in 
  531.         /usr/local, so the untar creates /usr/local/java/....
  532.  
  533.     <item> So you can run java as someone other than root (this is a
  534.         good idea!), do `chmod 666 /dev/zero'.   Red Hat and Caldera
  535.         have the wrong permissions set on this device out of the box.
  536.  
  537.     <item> If you haven't already, run ldconfig as root to load the new 
  538.         libraries.  If you do "ldconfig -v"  you can verify you have 
  539.         all the libraries loaded.  (At least we don't have to build
  540.         an ELF system first!)
  541.  
  542.     <item> Make sure you're logged in as a user (e.g. non-root).  Start X-
  543.         windows, open an X-Term, and try something!
  544. </itemize>
  545. </sect1>
  546.  
  547. <sect1> Unifix
  548. <p>
  549. Stefan Middendorf writes: Unifix is a popular German-language Linux
  550. distribution. There are a few distributions based on it: Linux Universe,
  551. sold in USA, Linux 4U, currently only distributed in Germany and Linux FT
  552. in Britain.  This recipe is known to work for Unifix 1.7, Linux 4U 1st
  553. Edition, Linux Universe 2nd Edition, and Linux FT 1.1.
  554.  
  555. <itemize>
  556. <item>Put linux-x86.jdk.static-motif.tar.gz from
  557.     <url url="ftp://www.blackdown.org/pub/Java/linux/">
  558.     in /usr/local and uncompress it and untar it.
  559.  
  560. <item>Change the first line of the script .java_wrapper
  561.       from PRG=`which $0` >/dev/null 2>&1 to
  562.  
  563.     PRG=`type $0 | cut -d ' ' -f 3` >/dev/null 2>&1
  564.  
  565. <item>Get libc-5.2.18.bin.tar.gz (I succeeded with libc-5.2.16.bin.tar.gz,
  566.     too), extract and uncompress it in the / drectory.
  567.  
  568. <item>Get ld-so.1.7.12.tar.gz from tsx-11.mit.edu (or any mirror site)
  569.     and uncompress and untar it, e.g. in /usr/local.  Change to the
  570.     resulting directory and run instldso.sh. This will also run ldconfig.
  571.     Probably newer versions of ld-so will work too.
  572.  
  573. <item>Add /usr/local/java/bin to the PATH environment variable.
  574.  
  575. <item>Get netscape-v20b4-export.i486-unknown-linux.tar.Z,
  576.     extract and uncompress it in /usr/local/<yourNetscapeDir>.
  577.  
  578. <item>Create a Link in /usr/local/bin to ../<yourNetscapeDir>/netscape. 
  579.  
  580. <item>Put /usr/local/<yourNetscapeDir>/moz2_0.zip in /usr/local/lib/netscape/.
  581. </itemize>
  582.  
  583. As an alternative to changing your PATH, Ralf Strobel suggests:
  584.  
  585. <itemize>
  586. <item> Copy the scripts .java_wrapper and appletviewer and the links @java
  587. @javac, @javadoc, @javap, and @jdb from /usr/local/java/bin to /usr/local/bin
  588. and you can use them wherever you are.
  589.  
  590. <item>In /java/bin/i586 you can add a script called `javadoc`
  591.  
  592.     #!/bin/sh
  593.     `dirname $0`/java sun.tools.javadoc.Main -d <yourhtmldir> $*
  594.  
  595.     where if you are user jrandom, <yourhtmldir> would be
  596.     ~jrandom/.java-html.
  597. </itemize>
  598. </sect1>
  599. </sect>
  600.  
  601. <sect> Viewing Applets
  602. <p>
  603. To run a demo without going through the applet viewer, you can enter this
  604. command from the top of my Java directory tree (/usr/local/java on most
  605. systems):
  606.  
  607.      bin/java sun.applet.AppletViewer demo/<directory_name>/exampleN.html
  608.  
  609. where <directory name> is the subdirectory off demo, and N is the 
  610. number of the example file (some directories have more than one).
  611.  
  612. Steve Greene says: I've started the tutorials available from Sun's java
  613. site and the similar one put out by the NTMUG.  I've discovered some
  614. problems with the syntax in Sun's tutorial, so I've been following the
  615. NYMUG tutorial instead for now.
  616.  
  617. The appletviewer expects as an argument, an html file with an
  618. APPLET tag inside it.
  619.  
  620. For example, if your html file Hello.html looks like:
  621.  
  622. <tscreen><verb>
  623.    <HTML>
  624.    <HEAD>
  625.    <TITLE> Hello test program &etago;TITLE>
  626.    < /HEAD>
  627.    <BODY>
  628.    This is an appletviewer test
  629.    <APPLET CODE="Hello1.class" WIDTH=150 HEIGHT=25>
  630.    < /APPLET>
  631.    < /BODY>
  632.    < /HTML>
  633. </verb></tscreen>
  634. (If you see "< /" in the above, ignore the space.  It's a workaround for
  635. a formatter bug.)
  636.  
  637. Running "appletviewer Hello.html" will show you the applet. One advantage
  638. of using the appletviewer is that events sent to the applet (start(),
  639. init(), etc) are in compliance with Sun specs as opposed to Netscape
  640. 2.0b4 (probably a bug in Netscape).
  641.  
  642. A disadvantage of using the appletviewer is that it is much slower than
  643. Netscape.
  644.  
  645. The first time you run Java, a license screen resembling Netscape's will be
  646. displayed.
  647. </sect>
  648.  
  649. <sect> Notes on Known Problems
  650. <p>
  651. <sect1> GNU Make breaks after I install Java
  652. <p>
  653. Recent versions of libc fix a bug which masked a bug in GNU Make (the
  654. symptom is that make doesn't look in Makefile for rules).  The libc 5.2.8
  655. release notes give a patch to make that fixes the problem.  You can also
  656. grab a fixed version from
  657. <url url="ftp://sunsite.unc.edu/pub/Linux/devel/make/make-3.74-direntfix-elf.tgz">.
  658. </sect1>
  659.  
  660. <sect1> You get `dirname: too many arguments' errors 
  661. <p>
  662. Your CLASSPATH variable is not correctly initialized.
  663. In .java_wrapper, there is code akin to the follwing:
  664.  
  665. <tscreen><verb>
  666.    PRG=`which $0`
  667.    J_HOME=`dirname $PRG`/..
  668. </verb></tscreen>
  669.  
  670. Unfortunately, linux's standalone which command is hideously broken, and
  671. certain shells will set $0 to the full pathname.  Randy Chapman says the
  672. fix is either to use:
  673.  
  674. <tscreen><verb>
  675.     J_HOME=`dirname $0`/..
  676. </verb></tscreen>
  677. Or, safer:
  678.  
  679. <tscreen><verb>
  680.     J_HOME=/usr/local/java
  681. </verb></tscreen>
  682. An alternate fix from Dave Dittrich is:
  683.  
  684. <tscreen><verb>
  685.     PRG=`csh -c "which $0"`
  686. </verb></tscreen>
  687. And another one from Tim Farnum is to change the PRG=`which $0` line to
  688.  
  689. <tscreen><verb>
  690.     PRG=$0
  691. </verb></tscreen>
  692. Lutz Behnke suggests:
  693.  
  694. <tscreen><verb>
  695.     PRG=`type -path $0` >/dev/null 2>&1 
  696. </verb></tscreen>
  697. A similar change also needs to be made to the appletviewer script.
  698. </sect1>
  699.  
  700. <sect1> You get `cannot find class java/lang/Thread' errors 
  701. <p>
  702. Your CLASSPATH variable is not correctly initialized.
  703. See above.
  704. </sect1>
  705.  
  706. <sect1> An error message refers to /dev/zero
  707. <p>
  708. Go root and do `chmod 666 /dev/zero'.
  709. </sect1>
  710.  
  711. <sect1> SEGFAULT
  712. <p>
  713. Occasionally, you may get a screen full of error messages, and the system 
  714. cheerfully fills up your swap space and locks-up.
  715.  
  716. You're probably missing a library someplace.  Rerun ldconfig -v and 
  717. see what's missing. Perhaps LD_LIBRARY_PATH or CLASS_PATH is not set.
  718. Finally, some applets are buggy or lock up the Linux JDK.
  719.  
  720. (BTW, you can stop the lock-up by having another Xterm open 
  721. with top running; use top to kill the java process BEFORE it 
  722. fills up swap and hangs your system!)
  723.  
  724. Java seems to want lots of resources, so I'd keep the number of 
  725. running/open apps on my desktop to a minimum.  It will load on 
  726. a 486DX-2-75 with 8 Mbytes RAM and 16 Mbytes swap (it'll take a 
  727. minute, though).  I was able to get two animation applets running 
  728. simultaneously (sort of) before my system ran out of swap space 
  729. and hung.
  730. </sect1>
  731.  
  732. <sect1> bin/java, bin/javac, or bin/appletviewer gives you a help screen
  733. <p>
  734. You left out some command-line parameter.
  735. </sect1>
  736.  
  737. <sect1> Applets show in the viewer but not when put on a web server
  738. <p>
  739. A common error which causes these results is failing to get the MIME type
  740. of the applet correct.  Your server should send a header with the applet
  741. indicating that its MIME type is "text/plain", "application/octet-stream",
  742. or some other type that doesn't have a defined special handler on the
  743. client side.  How you arrange this depends on which server you are
  744. using. (John Franks)
  745.  
  746. It's also been alleged that tinyhttpd, an HTTP server written in Perl, 
  747. returns a bad content type.  Apache, OTOH, is pretty reliable.
  748. </sect1>
  749.  
  750. <sect1> Problem Logging
  751. <p>
  752. Joey Oravec tells us that HotJava keeps a log of what it does and
  753. any problems in encounters. If you're up to diagnosing something yourself,
  754. look at $HOME/.hotjava/weblog in the user's home directory.  That file will
  755. make it more obvious if you're perhaps missing a library or something.
  756. </sect1>
  757. </sect>
  758.  
  759. <sect> Related Resources
  760. <p>
  761. Jeff Harrington maintains a Java hints page at
  762. <url url="http://www.parnasse.com/java.shtml">.
  763. <p>
  764. For general information on Java, there is a FAQ maintained on the 
  765. <htmlurl url="news:comp.lang.java" name="comp.lang.java">
  766. newsgroup; it is available at
  767. <url url="http://www.city-net.com/~krom/java-faq.html">.
  768. <p>
  769. There is an older FAQ-style document by Joey Oravec
  770. <url url="mailto:joey@sun.science.wayne.edu" name="joey@sun.science.wayne.edu">
  771. which primarily refers to the alpha release.  You can find it at
  772. <url url="http://www.science.wayne.edu/~joey/java/linux.html">.  At some
  773. point these documents may merge.
  774. <p>
  775. Here are some Java-related pages:
  776.  
  777. <itemize>
  778. <url url="http://substance.blackdown.org/java-linux.html" name="Karl Asha's
  779. General Linux Java Page">
  780. <url url="http://homer.ncm.com/java-linux/" name="LinuxJava Mailing List">
  781. <url url="http://www.cs.utexas.edu/users/hiep/netjav.html" name="Netrek for Java">
  782. <url url="http://cirrus.sprl.umich.edu/javaweather/" name="Blue-Skies for Java">
  783. <url url="http://www.parnasse.com/java.shtml" name="Java Hints Page">
  784. </itemize>
  785. </sect>
  786.  
  787. <sect> To Be Added... <label id="needed">
  788. <p>
  789. <itemize>
  790. <item> More recipes for specific Linux variants.
  791. </itemize> 
  792. </sect>
  793.  
  794. <sect> Acknowledgements
  795. <p>
  796. Grateful acknowledgement is made to all contributors, including:
  797. <itemize>
  798. <item>John Franks <john@math.nwu.edu>
  799. <item>Zachary DeAquila <zachary@zachs.place.org>
  800. <item>Steve Greene <sgreene@access.digex.net>
  801. <item>Dave Dittrich <dittrich@cac.washington.edu> 
  802. <item>Dave Flanagan <dave@ora.com>
  803. <item>Joey Oravec <mailto:joey@sun.science.wayne.edu>
  804. <item>Adam Smith <aws@cs.brown.edu>
  805. <item>Joe Buck <jbuck@Synopsys.COM>
  806. <item>Omar Loggiodice <ologgio@netdepot.com>
  807. <item>Stefan Middendorf <mdorf@stud.fh-heilbronn.de<
  808. </itemize>
  809.  
  810. This version incorporates Steve Greene's rumored but never-published
  811. Red Hat/Caldera mini-HOWTO.  I've also swiped some stuff I consider 
  812. useful off Joey Oravec's page -- special thanks to him.
  813.  
  814. For other HOWTOs and FAQs I maintain, see my home page at
  815. <url url="http://www.ccil.org/~esr/home.html">.
  816. </sect>
  817.  
  818. </article>
  819.  
  820. <!--
  821. The following sets edit modes for GNU EMACS
  822. Local Variables:
  823. fill-column:75
  824. End:
  825. -- >
  826.