|
To write Java programs you need some kind of Java development environment. The simplest one that you can get is Sun's JDK (Java Development Kit). The Sun JDK is a free collection of command line tools for developing Java programs. But the JDK is not too easy to use, since it is command line based, and it does not really contain all of the tools that you will need (for example, it lacks an editor and a debugger). Several companies have produced Integrated Development Environments (IDE's) that have all of the tools you might need to write Java programs and are easier to use than the JDK.
The CD-ROM that comes with our textbook contains an IDE, written by Borland, called JBuilder 3. This is a popular IDE and our textbook contains a fair amount of information about using it. But JBuilder is a fairly large program (for example, Borland recommends a minimum of 128MB of RAM to run the latest version, JBuilder 3.5). JBuilder is meant for professional programers and it contains a lot of features that we will never use in this course. In my opinion, a lot of what is in this IDE can get in the way of writing small programs like the ones you will work with in this course. It is important to learn how to use large IDE's like JBuilder, but you may, like me, find that working with a much smaller development environment is better for what we will be doing in this course. So in this page I want to give you some alternatives to using JBuilder. In particular, I will show you how to build a text editor based development environment. Building an IDE around a good text editor is a common way for programmers to do their work (especially with the UNIX and Linux operating systems). It has the advantage of creating a smaller, faster, and easier to use IDE. And by building your own IDE, you also get a sense of how the larger IDE's really work.
If you want to use an IDE, but JBuilder seems to large, two small IDE's that I think are good for what we will be doing in this course are KAWA by TEK-TOOLS, and JPad Pro by Modelworks. I will explain more about them later in class. Their only real disadvantage is that they are shareware, not freeware. (Both of these IDE's need the Sun JDK pre-installed.)
I will now explain how to install what I think is the simplest and most elegant IDE for writing small Java programs. Basically, what we will do is install the Sun JDK and then install a very good text editor as a "shell" or "wrapper" for using the JDK. Below are the steps to follow to install this combination of programs.
|
- Step 1:
- If you do not have the program WinZip already installed on your home computer, then you should install it first. Download the Windows 95/98/NT version from the WinZip Download Page; follow the instructions on that page to install WinZip.
- Step 2:
- Install Sun's JDK 1.2.2. Use the link at the end of this paragraph. The JDK 1.2.2 is over 20 MB, so expect the download to take several hours using a modem. To install the JDK follow the installation instructions from Sun's web pages. (It is probably a good idea to print out these instructions before installing the JDK.)
Sun's JDK 1.2.2 download for MS Windows
- Step 2.5 (Optional):
- The JDK does not come with any documentation. If you want the HTML version of the documentation, you need to install that separately. But the HTML version of the documentation is large (about 100MB installed) and not easy to use. Later in this page I will show you a better version of the documentation to install. But if you want the HTML version, read on.
The HTML version of the documentation comes in a zip file (that's why you need WinZip). Download it from the link at the end of this paragraph. Unzip the documentation to your
C:\ drive, not to the C:\jdk1.2.2\ directory; the zip file will automatically unzip itself into the proper subdirectory of C:\jdk1.2.2\ . (After you have unzipped the documentation, check that there is a docs subdirectory of C:\jdk1.2.2\ . That's where the documentation should now be.)
Sun's JDK 1.2.2 HTML documentation download
- Step 3:
- If you want to, you can test your JDK installation. Use the Start Menu to start up a "MS-DOS Prompt" window. At the DOS prompt, enter the following command.
C:\jdk1.2.2\bin\javac
You should get a "usage message" back from the Java compiler. Now use your favorite text editor to create the Welcome.java program from page 21 of our textbook. At the DOS prompt, use the cd command to move to the directory where you stored the file Welcome.java . Then compile Welcome.java with the following command.
C:\jdk1.2.2\bin\javac Welcome.java
After the program compiles, run the program with the next command.
C:\jdk1.2.2\bin\java Welcome
- Step 3.5 (Optional):
- In the last step we used the "full path name" at the DOS prompt for the Java compiler
javac and the Java interpreter java . If you want to work with Java from the DOS prompt, using full path names can be inconvenient. So you may want to set the Windows PATH variable to include the Java JDK. How to do this is explained in Step 5 of Sun's installation instructions. If you do not want to use the DOS prompt, then this step is not needed.
- Step 4:
- Download the TextPad text editor. TextPad is shareware; you can download and use it for free for a trial period, but then you are supposed to pay a shareware fee if you plan to continue using it. Use the following link to download the installation file (which is just over 2.4MB in size).
ftp://download.textpad.com/pub/textpad4.3/txpeng431.exe
- Step 5:
- Install TextPad by double clicking on the installer that you just downloaded.
- Step 6:
- Run TextPad by finding it in your Start Menu. Click on the Tools menu at the top of the TextPad window. You should see three commands for using Java at the bottom of the list. If you do not see the commands, try going to TextPad's Configure menu and click on the "Configure -> Preferences..." menu item, then click on "Tools" (not the little + sign next to "Tools"), then click on "Add" and then select "JDK Commands" from the drop down menu, finally click on "OK". (For more information on using the JDK with TextPad, and on TextPad's tools, click on the "Help -> Help Topics" menu item and use the "Index" tab to search for JDK).
- Step 7:
- Now it is time to test TextPad. Use TextPad to open your file
Welcome.java . Use the "Tools -> Compile Java" menu item to have TextPad run the Java compiler. Now use the "Tools -> Run Java Application" menu item to have TextPad run your program. Now deliberately put a mistake into your Java program by deleting a semi colon. Compile the program to see what happens. Double click on the line number in the compiler's error message to have TextPad jump to the offending line. Try using the keyboard shortcuts to compile and run your program.
- Step 8 (Optional):
- When learning Java, it is important to learn how to use Java's documentation. So now we will install an easy to use WinHelp version of the Java documentation. Open your
C:\jdk1.2.2\ directory and create a subdirectory called docs-win . Download the Windows Help File version of the JDK 1.2.2 documentation using the link at the end of this paragraph. (That link takes you to a page in France where the person who maintains these help files resides.) After you have downloaded the help file, use WinZip to unzip it into the C:\jdk1.2.2\docs-win\ directory that you just created.
Franck Allimant - WinHelp JDK 1.2.2 Documentation
- Step 9 (Optional):
- Now we need to create a tool in TextPad to use the help file we just installed. Start TextPad and go to TextPad's Configure menu and click on the "Configure -> Preferences..." menu item, then click on "Tools" (not the little + sign next to "Tools"), then click on "Add" and then select "Online Help File..." from the drop down menu. Use the dialogue box to navigate to the
C:\jdk1.2.2\docs-win\ directory, select the file Jdk122.hlp , click the "Open" button, click the "OK" button. Now look at the bottom of your list of TextPad tools in the "Tools" menu. There should be a tool called Jdk122. Once again open your Java program Welcome.java with TextPad. Use your mouse to highlight the word String , and then click on the "Tools -> Jdk122" tool menu item. This should bring up a help window about the String class.
- Additional Steps to Come:
- I will add some more steps that will show you how to add more Java online documentation and how to install the older, but still very important, JDK 1.1.8 to your development environment. In addition, I will show you how to add a nice C compiler, with Win32 API documentation, to your growing tool chest.
|
|
TextPad is a very powerful text editor. It has a lot of tools that make working with Java and HTML files much easier. Editors like Notepad or DOS's Edit really pale in comparison to an editor like TextPad.
When you are editing your Java source files with any editor, remember to save your work frequently (at least every 15 minutes), otherwise it may be Abort, Retry, Ignore?
|
|