Launch Java applications quickly from Windows 95

Find out how to save yourself some time -- with DOS command shortcuts

If you are using the Java Development Kit (JDK) to develop Java programs without the aid of an integrated development environment (IDE) under Windows 95, then you are probably quite used to having to create a DOS shell to run the application or appletviewer. This tip shows how to set up some command shortcuts to quickly and simply launch Java programs.

Instead of shelling to a DOS prompt and running the Java interpreter each time you need to run a standalone application (or the appletviewer), why not set up a DOS command shortcut? If you use the JDK and you, like many others, always want to be on top of the latest release, the first thing you should do is set up your path specification to use a Windows environment variable -- for example in the autoexec.bat file:

set JAVA=C:\jdk1.1.5
path %JAVA%\bin;C:\WINDOWS;C:\WINDOWS\COMMAND
set classpath %JAVA%\LIB\CLASSES.ZIP

This allows you to use the "JAVA" environment variable in the DOS command shortcut for greater convenience.

Now set up a DOS shortcut for the application, which for this example is the class file "parString.class":

Copy the standard DOS shortcut or right-click the desktop and select "New/Shortcut." Type in "command.com" and then edit the entries under the "Program" tab as follows:

Cmd line:  %JAVA%\bin\java.exe parString test.txt
Working :  C:\WINDOWS\Profiles\mig\Desktop\parstring

The Working directory entry is the location of any file that the Java application needs to read (as a command-line argument here). Note that the "Cmd line" path reuses the Java environment variable, so that if you upgrade your JDK, the shortcuts will still work.

With this application shortcut setup, to launch the application just double-click on the shortcut. This procedure also is very handy for using the JDK appletviewer in exactly the same manner:

Cmd line: %JAVA%\bin\appletviewer.exe testapplet.html

Note that the "Program" tab has several other useful setup features (like minimizing the DOS parent window when the Java application starts).

Sometimes, when a DOS application is launched from this kind of shortcut, a "not enough memory" failure results. This can be easily fixed by adjusting one of the "Memory" tab settings of the DOS shortcut. Select the "Initial environment" list and change it from the default "auto" setting to a value large enough to run the application.

Michel Gallant has worked for a major telecommunications company in Canada since 1981 in fiber-optic component research and development. His interest in Java programming stemmed from a desire to share custom modelling programs across multiple platforms on an international intranet. This distraction derailed his initial career direction and vectored him into a Web strategy role. He now promotes/evaluates Java as the language for network programming as well as organizes Web Development conferences. Oh yes, he is also the creator of the ubiquitous BOZZLE puzzle! Check out his Web page at http://infoweb.magi.com/~mig/.