Using the DOS command window
When you are using Windows as your development environment you will be using a DOS16 command window quite a bit. You can make this a little easier to use. First, you should put an icon on your desktop that is a link to command.com. Using Windows Explorer, find command.com (it’s in c:\windows\). Right click on command.com and select “copy.” Then right click on your desktop and select “Paste Shortcut.” You can double click on this icon to open a DOS command window. This opens a DOS window with the initial directory as c:\windows by default. You can change this to be your TINI development directory and assign a batch file to this DOS command window shortcut. Right-click on the icon we just put on your desktop and select properties and then pick the “Program” tab. Here you can enter the working directory and assign a batch file to be run whenever that DOS windows is opened. The batch file is run first and then the working directory is set. You can leave the working directory blank and use the batch file to change to the appropriate directory if you like, but as we tend to change this with each project, it’s simpler to change the DOS Prompt Properties.
Here is what I use for a batch file (javastart.bat in the example)
mode con: lines=43
doskey lets you use the up/down arrow keys to view previous commands and it keeps
a short command history. The mod con: lines=43 sets the DOS window to 43 lines of text.
We have not been using make or any other program development tool so far because we want you to see the CLASSPATH and command line options to the Java compiler and run time system so you can get comfortable with all of the options you need to use to develop TINI and 1-Wire applications. For the rest of the book, we will only show the CLASSPATH or command line options when they are significant. We will probably be using a batch file as mentioned above or make (as in GNUmake).
If you don’t have it installed on Linux, you can get it from the GNUmake web page17. Follow the Link for the make RPM. Download the RPM to a temporary directory and install.
% rpm -install make-3.79.1-7-i386.html
For Windows 95/98/NT/2000/XP, you will need to get Karl M. Syring’s “GNU utilities for Win32”18. This is a set of GNU tools that have been ported to the Windows environment. You can install the whole package or just pull the individual make program (and any others that you may want, like ls) out of the archive and stick them someplace that’s on your PATH (we use c:/opt/bin). Download the UnxUtils.zip files and save to a temporary folder. Using your favorite zip/unzip utility, extract the directory hierarchy in the temporary folder. Create a bin folder in the opt folder; this is where we will add our assorted utilities. If you already have a preferred folder for adding utilities, use that. Unzipping the UnxUtil.zip file will create a folder hierarchy similar to a Unix hierarchy for GNU tools. Using Windows Explorer, change to the usr\local\wbin folder that was created when you extracted the zip file. Find the make.exe file and copy it to your c:\opt\bin folder. Make sure this c:\opt\bin\ is added to your PATH environment variable in your autoexec.bat file using the same method we added to it in the previous paragraphs. If you are not familiar with GNU make, the complete GNU tool manuals can be found at the web site “Documentation of the GNU Project”19.
Here is a makefile that is the equivalent of the DOS batch file presented above. It does essentially the same thing. You need to modify the first three definitions in the makefile. This makefile will work on both Windows and Linux operating systems. You can certainly modify this makefile for more or less complex operation. You will need to consult the make manual20 for details on what you can do with make.
@javac -classpath $(CLASSES_T) -d bin src/$(PROG).java
@echo BuildDependency …
@java -cp $(tini_tools) BuildDependency -p $(build_p) -x
-d $(tini_db) -f bin -o bin/$(PROG).tini $(ARGS)
@echo sending $(PROG).tini to $(TINI) …
@echo open $(TINI)> ftptotini
@echo root>> ftptotini
@echo tini>> ftptotini
@echo send bin/$(PROG).tini>> ftptotini
@echo quit>> ftptotini @ftp -s:ftptotini
@lftp -e “put bin/$(PROG).tini;quit” -u root,tini $(TINI)
@echo PROG = $(PROG)
@echo ARGS = $(ARGS)
@echo TINI = $(TINI)
@echo MYTINI = $(MYTINI)
@echo OW_HOME = $(OW_HOME)
@echo TINI_HOME = $(TINI_HOME)
@echo CLASSPATH = $(CLASSPATH)
jEdit21 is a very nice editor for Java. It’s not absolutely necessary, since Windows Notepad and Linux’s vi do just fine. However, jEdit is a programmer’s text editor and so it makes writing Java significantly easier. It is released under the GNU General Public License. jEdit requires Java 2 (or Java 1.1 with Swing 1.1). It has an easy-to- use interface that resembles that of many other Windows and MacOS text editors, is extremely customizable, and has an extensive feature set that includes, among other things:
• Syntax highlighting
• Auto indent with support for intelligent indentation
• Search and replace with support for regular expressions, and searching in multiple files
• Bracket matching
• Multiple clipboards
• Split-window operation
• Word wrap
• Macro recording
• Support for plugins, which extend the editor’s functionality