context

- Avoiding Environment Variables -

author

I do not encourage beginners to alter the environment variables on their machines. Instead, I give them some shell files to execute.

In a file, command.cmd, on a Microsoft Windows machine:

javac -classpath ".;the full path name of the folder containing zio" %1.java

In a file, run.cmd, on a Microsoft Windows machine:

java -cp ".;the full path name of the folder containing zio" %1

My students place command.cmd and run.cmd in a folder with their Java programs. Alternately, these files could go into a folder on the existing PATH.

In a file, command, on a Linux machine:

javac -classpath ".:the full path name of the directory containing zio" $1.java

In a file, run, on a Linux machine:

java -cp ".:the full path name of the directory containing zio" $1

My students usually place command and run in a folder containing their java programs and make them executable. Alternately, these files could go into a directory on the existing PATH.

If their OS isn't finding their javac and java programs, students need to replace javac and java with their full path names.

If using the zio.jar file then the path name mentioned above should be the complete path name of this file rather than the path name of the zio directory.

When setup as described, students can compile and execute this way on either a Windows or a Linux machine.

compile ProgName
run ProgName

contextJul 1, 2005author