From: Corey Snow Newsgroups: comp.lang.java Subject: comp.lang.java NEWBIE FAQ v1.0 Date: Mon, 27 May 1996 12:32:32 -0700 Organization: Cybergate, LLC Document Title: comp.lang.java Newbie FAQ Posting Frequency: weekly Last Modified: 20 May 1996 Maintainer: Corey Snow (thekeep@kendaco.telebyte.com) Version: 1.0 This article is a Frequently Asked Questions list intended to address most questions asked by those new to Java. This FAQ does not address advanced issues/questions; it is not intended to be the definitive FAQ for comp.lang.java. I will leave that to those better able to create such a document. :) This is an EVOLVING DOCUMENT. It is by no means complete, nor does it pretend to be. I expect that some major revisions will be taking place in the next few weeks, as I recieve feedback (hopefully) and contributions to this FAQ. My hope is that this will become a valuable resource for newcomers to Java; a single resource that spells out what it is, where you can get it, and where to go to learn more. It's a far cry from that now, but I will keep working on it. 27 May 1996- It turns out that there's another FAQ out there which covers most of the same topics and has been around longer. However, I will continue to do this FAQ as long as there's interest, because I'm really learning a lot about Java doing this FAQ. Check out http://sunsite.unc.edu/javafaq/javafaq.html for another FAQ on Java, which is very well done. Contributions, comments, corrections, flames, and any other correspondence regarding this FAQ should go to: Corey Snow thekeep@kendaco.telebyte.com ---------LEGAL STUFF:----------------------------------------- Java(tm) and JavaScript(tm) are trademarks of Sun Microsystems, Inc. Sun, Sun Microsystems, Sun Microsystems Computer Corporation, the Sun logo, the Sun Microsystems Computer Corporation logo, Java and HotJava are trademarks or registered trademarks of Sun Microsystems, Inc. UNIX(R) is a registered trademark in the United States and other countries, exclusively licensed through X/Open Comapny, Ltd. Netscape(tm) is a trademark of Netscape Communications Corporation. Microsoft Windows, Windows 95, and Windows NT are trademarks of Microsoft Corporation. All other product names mentioned herein are the trademarks of their respective owners. DISCLAIMER: This document is provided as is, with no guarantees as to relibility of the information it contains. This document may contain errors- USE THIS DOCUMENT AND THE INFORMATION IT CONTAINS AT YOUR OWN RISK. Under no circumstances will Corey Snow be held liable for any problems that may occur due to your use of this document or the information it contains. ---------End of Legal Stuff------------------------------------ This document addresses the following topics: 1) Preface 1.1) Acknowledgements 1.2) Revision History 1.3) Submitting Corrections to this FAQ 1.4) How can I help? 1.5) Where else can I obtain this FAQ? 2) General 2.1) What is Java? 2.2) Who makes Java? 2.3) Where did Java come from? 2.4) What does JAVA stand for? 3) The Java Developer's Kit (JDK) 3.1) What is the JDK (Java Developer's Kit)? 3.2) Where can I get the JDK? 3.3) How do I install the JDK? 3.4) Where's the documentation for the JDK? 4) Learning Java 4.1) Do I need to know C/C++ to learn Java? 4.2) Do I need to know [insert any language here] to learn Java? 4.3) What's the difference between Java and JavaScript(tm)? 4.4) What's a Java "applet"? 4.5) What's a Java "application?" 4.6) How do I write Java applets/applications? 5) HELP! I'm having Problem X! 5.1) General Problems 5.2) Problems with JAVAC (the Java Compiler) 5.3) Problems with JAVA/JAVAW (the Java Interpreter) 5.4) Problems with Java Applets in Netscape 6) Resources 6.1) Online Tutorials 6.2) Online Resources 6.3) Code archives, examples, etc. 6.4) Books, references, etc (paper-based) 1) Preface Welcome to the comp.lang.java Newbie FAQ (Frequently Asked Questions) list. I decided to put this document together after spending some time browsing the comp.lang.java newsgroup for information, and noting that most questions fell into two general categories- those from total newbies (like myself) and those from people who were already familiar with programming and programming concepts. Needless to say, the second group's questions and answers are usually incomprehensible to the first. It also seemed that the "newbie" questions were often going unanswered, or were being answered partially or even incorrectly. Most of the FAQs out there, while very well done, didn't cover the *real* basics, except in a general sense. In my personal learning experience, I had to spend quite a bit of time jumping from place to place, getting a question answered here and there. So, I decided, with some encouragement from a few comp.lang.java net.peoples, to put together a document which *attempts* to answer the basic questions. It does NOT address more advanced topics; I am neither qualified nor inclined to take on that duty, and there are already several outstanding resources for more advanced topics. This is an evolving document; corrections, additions, comments, and questions can be directed to Corey Snow at the email address thekeep@kendaco.telebyte.com. 1.1) Acknowledgements. The following individuals have contributed their expertise, observations, or knowledge to this FAQ- my thanks go out to them. Juan Cabanela juan@astro.spa.umn.edu Sarang Gupta proveit@Rt66.com 1.2) Revision History 20 May 1996: Created comp.lang.java Newbie FAQ v0.9 27 May 1996: Incorporated several corrections: removed references to UNIX as a specific OS; clarfied the difference between Solaris and SunOS (Thanks to Sarang Gupta!) and made some other revisions mainly for the purposes of clarity. Also corrected numbering error in section 3. Added information on MacOS (Thanks to Juan Cabanela!) JDK and installation of same. Added section 5.3- problems with the Java interpreter. Changed version number to 1.0. 1.3) Submitting Corrections to this FAQ This FAQ may (may, my foot- I *know* it does) contain errors. If you find something in this document which needs correcting, updating, etc, please inform me at thekeep@kendaco.telebyte.com. Replies to the newsgroup may or may not be seen, so if you write your reply there, please CC my email address! I'll do my best to get any corrections in the next week's release of this FAQ. No guarantees, of course, but I'll try to make this as current a document as possible. 1.4) How can I help? There's lots of ways you can help! The main way is to read the FAQ and see if there's something you'd like to see in it. If so, send it to me, preferably as a question *with* an answer, for inclusion in the next release. If I don't think it's appropriate to this FAQ (too advanced, already addressed elsewhere), then I'll let you know as soon as possible. If a question is too advanced for this list (Remember, this is a NEWBIE FAQ!), then I can send it to other FAQ maintainers for potential inclusion in their lists. Any FAQ maintainers out there interested? 1.5) How else can I obtain this FAQ? This FAQ will be posted every Monday to comp.lang.java. Also, the latest edition can be obtained by sending email to: thekeep@kendaco.telebyte.com with the words 'GET JAVAFAQ' in the SUBJECT: line. The next time I check my email, it will be sent to you. You should also be able to obtain a copy soon at the Java Oasis (http://www.oasis.leo.org) at the URL: http://www.oasis.leo.org/java/documentation/faqs/00-index.html Note that I am not in charge of, nor do I have anything to do with, the Java Oasis. I gave permission for a copy of this document to be placed on their servers, primarily because then I don't have to put it on a WWW page. If the copy on their systems is out of date, let them know. 2) General This section (Section 2) is devoted to general Java questions, such as "What is Java?" (2.1) and "What does JAVA stand for?" (2.4) 2.1) What is Java? Java is a full-featured programming language, loosely based on C++. It is object-oriented, platform independent, interpreted, and robust. 2.1.1) What does (2.1) mean? :) Java is a very exciting technology. It is a programming language, similar in many respects to C++, but without many of the complexities that make C++ so difficult to learn. In most programming languages, one writes code and compiles that code into native instructions for one specific platform, such as Windows95, MacOS, Linux, OS/2, AIX, IRIX, Solaris, etc. The code written for one platform wouldn't be useful on another platform without major editing (called 'porting') of the source code. Java bypasses this. Programs written in Java can be viewed with a Java interpreter on any platform. Currently, Java interpreters exist for many platforms, including (but not necessarily limited to): Windows95, OS/2, Unix, Solaris, and MacOS. This is because Java code is not compiled into native instructions for one platform, but into a generic format called 'bytecodes'. The resulting file can be viewed by a Java interpreter on any platform (assuming one currently exists for that platform). (2.1.5) In addition, although Java is loosely based on C++, it does not have many of the potential problems associated with C++ (and some other programming languages), such as pointers, memory management, etc. Java attempts to correct many of these potential problems and make life easier on the programmer. The intent of Java is to allow the programmer to focus more on the program, rather than all the background work. 2.1.2) How is Java similar to or different from C++? Java has been called a "subset" of C++, although this is not strictly accurate. Much of its syntax, code structure, etc, are very similar to C++, although it can be radically different at times. The following list details some of the major differences between Java and C++ (not a comprehensive list by any means): No multiple inheritance- rather Java uses a methodology called "implements". Objects can inherit from one other object- their parent. No destructors- Java implements automatic garbage collection and memory management, hiding these details from the programmer. Much stricter type- and bounds-checking. Java has no pointers. 2.1.3) What does Object-Oriented mean? Java is an 'Object-Oriented' language. A discussion of OO concepts is beyond the scope of this document except in the most general terms. OO means taking data and 'bundling' that data with the instructions needed to manipulate it. The resulting structure is called an 'Object' or in Java terms, a 'Class'. If you are unfamiliar with Object-Oriented programming concepts, I HIGHLY recommend that you spend some time familiarizing yourself with the basics before going too much further with Java. A good introduction to OO is available at: http://java.sun.com/tutorial/java/objects/index.html If anyone knows of any other resources for Object-Oriented programming basics, please let me know so that I can include them here. 2.1.4) What's Platform-Independent mean? Platform-Independent means that compiled Java programs will (in theory) run on any platform for which there is currently an interpreter (2.1.5). In practice, this is very nearly the case. However, it is currently somewhat rare to create a program which works perfectly on all platforms. This is for a number of reasons, but mostly because Java is a very new technology. The solution is to simply test your programs on multiple platforms- if you don't have a UNIX box, ask your net.buddy to test it out for you. Call your OS/2 holdout friend and ask them to try out your program on their system. It is usually possible to correct whatever flaws there are that only show up on platform X. Java is platform-independent, just not perfectly so, yet. Welcome to the 'bleeding edge'. :-) 2.1.5) What does 'Interpreted' mean? Interpreted means that a compiled Java program won't run on its own. It needs another program, called an 'interpreter', to run it. This is done for platform independence. An interpreter can be written for operating systems A, B, C, X, Y, and Z, and you can write a Java program on operating system D which will work on all of the above! Java programs are actually written for an abstract computer called the "Java Virtual Machine", JVM or VM for short. This is what gives Java its cross-platform independence; the only thing that has to be written for a specific platform is the implementation of the VM for that platform- known as the interpreter. The Java Virtual Machine Specifications, for those who are interested, is available at http://java.sun.com/. Java interpreters are already written for many platforms, with others currently underway. (3.3) There are also Web browsers, such as Netscape, which are 'Java-aware', or can run Java programs. The types of programs that Web browsers run are called "applets" and are addressed in section (4.4). Standalone Java programs, which are run with an interpreter, are called "applications" and are addressed in section (4.5). 2.1.5) What do you mean by 'robust'? Robust- powerful, flexible, etc. There's an ongoing debate in comp.lang.java in multiple threads about Java's capabilities (or lack thereof). The bottom line is, try it out, and see what you think. Some people are very frustrated with Java, and some see it as the "Holy Grail" of programming. YMMV. :) Another thing to keep in mind is that Java is very new technology, and its capabilities are mostly potential right now. I expect that the functionality will increase massively over the next few months/years, as more programmers get into the Java act and start writing their own libraries. (just a few thoughts.) 2.2) Who makes Java? Java is created by JavaSoft, which is a division of Sun Microsystems, Inc. (R). More information is available at their Web Site: http://java.sun.com/ Information on Sun Microsystems is available at: http://www.sun.com/ In addition, many other companies have created their own Java implementations. [I need a products list. Anyone?] 2.3) Where did Java come from? Java has a long and sordid (well, not sordid, but it sounded good) history. I'm not qualified to tell it, but I'm sending email to a couple of people who have written Java books, asking for permission to quote their "history of Java" chapter here. If anyone else would like add to this, let me know! 27 May 1996- I'm still working on this section- hopefully by the next edition- Corey. 2.4) What does JAVA stand for? Nothing. Really. The Sun folks were trying to come up with a name (this is how I heard it, no flames, please! :) and decided on Java as something that sounded cool, plus was the name of the programmer's favorite drink (Well, some prefer Jolt, but that's just a matter of taste). But some of the funnier ones I've heard (culled from comp.lang.java) with credit to the creators, or to the person that typed it in the newsgroup: "Just Another Virtual Architecture" - David Hopwood "Just A Verbose Acronym" - Marty Hall "Java Acronyms Vary Alot" - Marty Hall "Just Another Vicious Abbreviation" - Stefan Koch 3) The Java Developer's Kit (JDK) The Java Developer's Kit (hereafter called the JDK) is the package of software tools made available by JavaSoft to create Java programs. This section is devoted to questions on where to get it, how to install it, and where the documentation is. 3.0.1) How are Java programs written? A tutorial on Java syntax is beyond the scope of this document; however, it would still be useful to discuss the basic concepts of creating Java programs. When writing Java programs, one creates a plain text file containing the source code. This text file is saved with an extension of '.java'; for example, 'myProgram.java'. This file is then compiled using the javac compiler (3.1.1). The javac compiler will generate a file with the same primary name, but the extension 'class'. So 'myProgram.java' would be compiled to 'myProgram.class'. This 'class' file is the one which is loaded into the Java interpreter (3.1.2) and executed. 3.1) What is the JDK? The JDK (Current version: 1.0.2) is a package of software tools created by JavaSoft (Sun) which enable you to create Java programs. The tools include the following: (each is explained in the following sections) javac Java Compiler java Java Interpreter jdb Java Debugger javah C Header file Generation Program javap Prints a representation of compiled bytecodes javadoc Documentation generator- creates API documentation from comments in source code appletviewer Allows viewing of applets without a Web browser All of these tools are run from the command line! Some of the newer IDE (Integrated Development Environment) tools available handle the nasty details of typing in compiler commands, but you'll have to consult your own docs on that. This FAQ only covers the JavaSoft JDK. The complete tool documentation is available on the Internet at http://java.sun.com/products/JDK/tools/ This includes platform-specific documentation, NOTE: The MacOS documentation is not yet available, although the docs for the Win95 platform should be close- keep in mind that MacOS has no commandline, so the appropriate commands are entered in a dialog box. 3.1.1) What is javac? The Java Compiler, or javac is the "heart" of the JDK. It is the program you use to compile Java code into bytecode files, which have an extension of .class. The resulting *.class file can then be loaded and run in the Java interpreter (3.1.2). The simplest form of the command line for javac is: javac file.java Consult your specific platform documentation for options you can use with the javac compiler (see 3.1) MacOS users- my understanding is that you launch javac by double-clicking its icon, and entering the appropriate information in a dialog, rather than at the command- line. 3.1.2) What is the Java Interpreter? The Java interepreter (java) is the program which you must execute to view Java applications (NOT applets). Assuming that you already have a compiled Java file (3.1.1), the command line is: java filename Note the lack of the '.class' at the end. This is assumed- don't add it! If you do, the interpreter will fail. You can use this to view any Java program, except applets. If you wish to view applets, see (3.1.7) Note for Windows95 users- the JDK also comes with a program called javaw which is exactly the same as the normal Java interpreter, but which doesn't open a DOS prompt window along with the main Java program. There is no difference otherwise. [Is this the case with other OSes, also?] 3.1.3) jdb - The Java Debugger This section is pending. Anyone wanna take a stab? :) 3.1.4) javah - Generating C Header and Stub files This section is *definitely* pending, until someone who knows how to use this tool comes along and submits an explanation :) 3.1.5) javap - Print a representation of compiled bytecodes Used to print out a representation of a compiled *.class file. I'm not familiar enough with this tool yet to offer a real explanation beyond that. 3.1.6) javadoc - Autogenerate API documentation The javadoc program is used to create automatic HTML documentation of your classes based on comments you enter in the source code. This is not a newbie topic, but bears mentioning. You can enter comments in your source code in a special format which javadoc can use to create a series of HTML files. 3.1.7) appletviewer - View applets without a Web browser The appletviewer program is used to provide the services of a WWW browser without having to actually run one. You first have to have an applet *.class file, of course, but you also have to create the associated HTML file. The HTML tag for denoting an applet is: Create an HTML file with the above code, specifying the appropriate filename, height, and width, and save it in the same directory as the applet *.class file. Run appletviewer on it by typing appletviewer file.html at the command prompt. NOTE TO WINDOWS 95 USERS: The first thing you see when you run appletviewer is a License Agreement with Accept and Reject buttons. However, these buttons can be hidden under the Taskbar on many systems! The solution is to drag the Taskbar to another section of the Desktop by clicking on a blank (non-button) area and dragging it. Drag it to the top or side of the desktop to move it and you should see the Accept/Reject buttons. 3.2) Where do I get the JDK? The latest version as of this writing is 1.0.2. The JDK is available in many places, for many platforms. Visit http://java.sun.com/ For the latest versions released by Sun. Below is a list of platforms and locations where you may obtain the JDK for that platform or more information on Java for that platform. Win95, WinNT(x86) (3.3.1) SPARC Solaris 2.3, 2.4, or 2.5 (3.3.2) x86 Solaris 2.5 (3.3.3) MacOS System 7.5 (3.3.4) IRIX (3.3.5) OS/2, AIX (3.3.6) Linux (3.3.7) Other OSes (3.3.8) [NOTE: I have just discovered that ftp.blackdown.org is closed to the public for some reason. The mirrors that they have listed only seem to carry the 1.0.1 JDK. Does anyone know if there's any other mirror sites that I can list here?] 3.2.1) Windows95, WindowsNT (Intel x86) ftp://ftp.javasoft.com/pub/JDK-1_0_2-win32-x86.exe 3.2.2) SPARC Solaris 2.3, 2.4, 2.5 ftp://ftp.javasoft.com/pub/JDK-1_0_2-solaris2-sparc.tar.Z 3.2.3) x86 Solaris 2.5 ftp://ftp.javasoft.com/pub/JDK-1_0_2-solaris2-x86.tar.Z 3.2.4) MacOS System 7.5, 68030 or better processor BinHex Format: ftp://ftp.javasoft.com/pub/JDK-1_0_2-MacOS.sea.hqx MacBinary Format: ftp://ftp.javasoft.com/pub/JDK-1_0_2-MacOS.sea.bin 3.2.5) IRIX This doesn't seem to be a JDK per se, but it mentions Java in a few places, so if you use IRIX, check out Cosmo at: http://www.sgi.com/Products/cosmo/cosmo_instructions.html I really didn't explore it too deeply, maybe when I have time... :) 3.2.6) OS/2 and AIX Visit the following WWW Site for information on Java for OS/2 and AIX: http://ncc.hursley.ibm.com/javainfo/ 3.2.7) Linux For all you Linux hacks, there is a port of Java available, and you can find all kinds of info at http://www.blackdown.org/ including a list of FTP sites. 3.2.8) Other OSes Any others, folks? Let me know! If you use Windows 3.x, you're probably just about out of luck. Rumor has it that IBM is working on a port to Windows 3.x, but I wouldn't hold my breath. 3.3) How do I Install the JDK? Well, this varies widely depending on your platform. In basic terms, you should do the following: FIRST, visit Sun's Website, which contains much better instructions than what's here. Go to http://java.sun.com/products/JDK/1.0.2/ For complete downloading and installation instructions. 3.3.1) Extract the compressed archive. Ensure you enable your decompression software's "create directories stored in archive" option enabled! This will create a directory tree on your hard disk containing the directories java java\bin java\lib java\demo java\include For UNIX flavors, of course the "\" character will be "/". I come from a Win95 background- someone inform me if this info is inaccurate for a given platform. Windows95/NT users get a self-extracting archive. Run it in the root directory to create the appropriate subdirectories. MacOS users probably don't need to worry about most of this- the "installer" should handle it. [NOTE: Need Mac-specific Info here! Tips, tricks, pitfalls!] There will, of course, be quite a few files included in these directories. There will be two ZIP files, src.zip and classes.zip. DO NOT UNZIP OR DECOMPRESS THE CLASSES.ZIP FILE! If you wish, you can unzip the src.zip file, which will create a directory java\src\ with all kinds of fun source files to explore. For MacOS users, the JDK comes with an Installer- simply launch it to install the Java Developer's Kit. If it fails, restart your Mac and hold down the SHIFT key until the system boots to start with extensions disabled. Then try running the JDK installer again. (thanks to Juan Cabanela for information on MacJDK). 3.3.2) How do I set my environment variables? Now this varies quite a bit from platform to platform. Basically, you must add java and java\bin to your search path and set the CLASSPATH variable. 3.3.2.1) Win95/WinNT users Edit your autoexec.bat to include the following: PATH=(LEAVE YOUR CURRENT PATH THERE);C:\JAVA\C:\JAVA\BIN; SET CLASSPATH=.;c:\java\lib\classes.zip Change the above as necessary to reflect where you actually installed the Java files. ENSURE THE CLASSPATH VARIABLE IS PROPERLY SET! If it isn't, your compiler won't work. Period. The ".;" is important- it isn't a typo, put it in. If you don't, the javac compiler won't bother to look in your current directory for *.java files to compile. 3.3.2.2) UNIX flavors, Solaris, and others: You need to set the proper environment variables. I don't know enough about the various flavors to say for certain, but usually you'll want to edit the .cshrc file or similar. You need to include the command: setenv CLASSPATH .:/usr/local/java/lib/classes.zip Ensure you set this properly, and use a colon ":", not a semicolon, as you would on Win95/NT machines. Note: Netscape Navigator apparently has a conflict with the JDK- they both use the CLASSPATH variable (this doesn't apply to MacOS or Win95 users)- Netscape requires it to be: setenv CLASSPATH /usr/local/lib/netscape/moz3_0.zip - This may be slightly different on your system. I understand that on most platforms, combining the two variables into one doesnt' work. Probably what you'll need to do is create a shell script that simply changes the variable as needed. Anyone have a sample that people could use? Or other information on this issue? I'm really operating in the dark, as I use Win95 and OS/2 mainly. You also need to add java/bin to your search path. I've been informed that this works pretty much on all UNIX flavors if you're running csh (the C-Shell). If you run something different, (bash, ksh, etc), then you may have to modify these instructions for your specific situation. I would appreciate any information on setting up the JDK on different implementations. 3.4) Where's the documentation for the JDK? If you're using the JDK obtained from Sun, visit http://java.sun.com/products/JDK/tools/ Currently the only tool documentation available is for Win95/NT and Solaris. 4) Learning Java This section is devoted to learning how to use Java effectively. It isn't a tutorial, but rather just a compilation of some questions that most newcomers to Java ask. 4.1) Do I need to know C or C++ to learn Java? Opinion is divided on this issue in comp.lang.java. I'm a newbie to Java myself, but I've picked up quite a bit in a short time, and I only know enough C to recognize it when I see it, and so I'm going to say that knowing C is not a requirement. Knowing C or C++ certainly couldn't hurt, as it will give you a leg up on learning the syntax of Java, but that's it. The main requirement for learning Java is that of any other language- you'll have to learn how to program. If you don't understand programming, you should learn. Pick up a book on programming in general, or better yet, a book on Java programming designed for newcomers to programming. If you have programmed at all, you probably have at least the basic skills which will enable you to figure out Java. Anecdotally, I hadn't programmed ever before except in BASIC (ugh) and a tiny bit in Pascal (read- one 200 line program) before coming to Java- I downloaded the JDK on May 5, 1996. So, I am still very much a newbie, but getting better. I offer this short story to you as proof that it's not that hard. :-) 4.2) Do I need to know [Insert Any Language Here] to learn Java? See (4.1) :) 4.3) What's the difference between Java and JavaScript(tm)? Java is a programming language developed by Sun. JavaScript is a system for embedding scripts in the content of HTML documents, which can then be executed by Web browsers such as Netscape. Other than the name, the two have nothing to do with each other. See the USENET newsgroup comp.lang.javascript for further information on JavaScript. 4.4) What's a Java "applet"? An applet is a Java program executed within the context of a WWW page. A Web browser, such as Netscape or WebExplorer, which visits the page, sees the tag it will load the specified *.class file and execute it in a window whose size is specified by the HEIGHT and WIDTH attributes. Java applets are generally *intended* to be smaller than standalone programs, but nothing enforces this. Applets can be any size, although it is recommended that they be as small as possible to reduce network transmission time. 4.5) What's a Java "application"? A Java application is a Java program which is run with the Java interpreter and doesn't require a Web browser. Java applications cannot be run with a Web browser, only the interpreter. Java applications tend to be larger than applets, although this is not a hard and fast rule. 4.6) How do I write Java applets/applications? Java applets and applications are written differently. Explore some of the online resources available to learn the differences. Once you understand how to create one, learning how to create the other is easy. A good starting point is: http://java.sun.com/tutorial/index.html which is an online tutorial in Java, containing examples, code samples, and step-by-step instructions. 5) HELP! I'm having problem X! This is the section devoted to answering problem questions. It will grow over time. I expect it to grow faster than any other section, and I will continue to add to it over time. Send questions you'd like to appear in this FAQ (with the answers, if possible) to me! (thekeep@kendaco.telebyte.com) 5.1) General Problems Most problems that I've seen from new users seems to be related to the CLASSPATH environment variable. Ensure that this is set properly! 5.1.1) Naming Conventions Your source code file MUST have an extension of *.java. (e.g., myProgram.java) The *.class file that is generated gets its name from the primary classname in the source code file. In other words, if I have a program called 'myProgram', it must name the primary class in the file as follows: public class myProgram {... //Do whatever this program does. } This source file must be saved to myProgram.java, and if I type javac myProgram.java I will have a file called myProgram.class, which is the compiled version of myProgram. To run myProgram, I would type java myProgram Note that there is no '.class' at the end. 5.1.2) Case Sensitivity Java is case sensitive! If you type files/names, etc. in the wrong case, an error will usually result. Check to be sure that you use the proper case. Also ensure that the CLASSPATH environment variable is properly set. If it is not, javac may not be able to find files in the current directory. 5.2) Problems with javac - the Java Compiler This section addresses specific questions relating to the javac compiler. 5.2.1) Error: "can't read:file.java" Check the CLASSPATH. Ensure that it's correct.(3.4.2) Check the spelling- did you spell the file name properly? (5.1.2) Did you save the source code with an extension of *.java? NOTE- on Windows95 machines, saving a file from Notepad can result in a filename like 'file.java.txt'. Check this to be sure. 5.2.2) Error: "Public class XXXX must be defined in a file called xxxx.java" Check that you typed the filename in the proper case- myProgram.java is different than myprogram.java. Check that the primary classname in a file is the same (with the same case) as the source file name. For example, the file myProgram.java must contain a primary class called myProgram, which will generate the file myProgram.class when compiled. (5.1.1) 5.2.3) Error: "Type expected." This one is almost ALWAYS due to having mismatched "{ }" pairs. Ensure that you haven't added an extra } or { somewhere which is confusing the compiler. 5.3) Problems with java/javaw - The Java interpreter This section is to address problems with viewing Java applications using the Java interpreter (java). 5.3.1) Error: "can't find foo/class" You typed the full filename of the classfile. Use only the primary name of the file- for example, if your classfile is called foobar.class, the command to run it is: java foobar Check your CLASSPATH variable also. (3.3.2) 5.3.2) Error: "Can't find foo" You typed a non-existent filename for the classfile. Ensure that you are in the right directory and that your CLASSPATH environment variable is properly set.(3.3.2) 5.4) Problems with viewing Java applets in Netscape (and other Web browsers) This section is under development. 6) Resources This section is devoted to resources, both online and off-, for beginning Java programmers. I will list tutorials, FAQ archives, WWW sites, and books. Any suggestions for this section, send them my way (thekeep@kendaco.telebyte.com) 6.1) Online Tutorials First, there's the one at JavaSoft- http://java.sun.com/tutorial/index.html This is an online "preview" version of a book that's coming out this fall (I believe). This is a great place to start. 6.2) Online Resources Here's a short list. I'll add more as I get them. http://java.sun.com -Sun's Java Site http://sunsite.unc.edu/javafaq/javafaq.html -The Official comp.lang.java FAQ. I highly recommend checking this one out; the creator has done an outstanding job. http://www.digitalfocus.com/digitalfocus/faq/howdoi.html -How Do I... by Digital Focus. Outstanding! http://www.javaworld.com -JavaWorld, an online magazine for Java developers. http://www.gamelan.com -Gamelan, a really cool Java Resource site. http://www.acm.org/~ops/java.html -Java Resource Site 6.3) Code archives/Libraries, etc. http://www.entmp.org/jcw/ -Java Class Warehouse, a site for sharing Java code among developers. 6.4) Books I definitely need some more listed here. However, I only have a couple, and although I know of a couple more, I don't have the author's names, ISBN Numbers, prices, or Copyright info. Send me your favorite Java book/tutorial title, author, and publisher for inclusion here! Just Java ISBN: 0-13-565839-X Peter van der Linden (C) SunSoft Press, 1996 $34.95 99.9) That's it! (For now!) Hopefully, this document will answer some questions- I know that it doesn't answer all of them, or even most. But it will get better every time. :) Comments, suggestions, contributions, corrections, discussion, philosophy, philanthropy, and phlames can go to: Corey Snow - thekeep@kendaco.telebyte.com Comments are welcome. Thanks! --------------276401E2A4E--