Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: can i build new external commands?  (Read 4073 times)

0 Members and 1 Guest are viewing this topic.

chris milne

  • Guest
can i build new external commands?
« on: July 31, 2004, 02:38:22 PM »
Hi,
firstly, i'm a bit of a newbie to DOS, so sorry if this's really easy!
secondly, i've tried the FAQ pages and searching the forums but i can't find an answer to my problem...

Ok, what i've been trying to do is install a Java Development Kit in Windows XP.  I usually use Linux to do this kind of stuff, so what i'd like to do is to be able to type in commands in DOS ,e.g. 'javac' (that's the compiler), and for them to work regardless of which directory i'm currently in.
Here's an example:
just say i'm in directory c:\chris and i want to compile a file, HelloWorld.java.  I can compile the file if i type in:
c:\jdk1.31\bin\javac HelloWorld.java
i.e. the full path to the compiler, then the filename.
but... because i'm super lazy ;) i just want to type:
javac HelloWorld.java

i've tried putting shortcuts in c:\windows\system32 (that's where external commands seem to be stored?) to the javac.exe program and i've even tried to copy javac.exe to there but it doesn't work (it can't find the necessary libraries).

is there anyway that i can, sort of, choose which directories i want the command prompt to search through to find the executable files?


many thanks for reading, it'd be amazing if someone could help me out...
Chris.

MalikTous

  • Guest
Re: can i build new external commands?
« Reply #1 on: July 31, 2004, 02:46:34 PM »
I think there are some environment variables (set java=c:\progra~1\java141 or something similar) you can use to aid this. Check your documentation. Include the JAVA directory in your PATH statement, as well. Set these in your DOSSTART.BAT or similar file.

johnwill

  • Guest
Re: can i build new external commands?
« Reply #2 on: August 01, 2004, 02:46:01 PM »
Sure, it's called the PATH variable.  If you put any directory you want to be searched for executables on the path, DOS will find them anywhere you invoke them from.

Note that you may need to be logged into that directory for the application to function properly, I do that by having a \BAT directory with command files to do whatever I require for a given command.  You can do many tasks with batch files in this manner.  For example, here's a handy little batch file that takes a snapshot of a directory and keeps a number of generations of it in ZIP files.  I use it when I'm developing code to keep generations.  You can also expand the number of generations just by adding more rename commands.


@echo off
@rem
@rem This batch job does a daily backup of the current directory into
@rem a subdirectory called DAYBACKS under the current directory.  If
@rem the DAYBACKS subdirectory doesn't exist, it is created.
@rem
if not exist daybacks\nul mkdir daybacks
cd daybacks
if not exist day1.zip goto noday1
if exist day10.zip erase day10.zip
if exist day9.zip ren day9.zip day10.zip
if exist day8.zip ren day8.zip day9.zip
if exist day7.zip ren day7.zip day8.zip
if exist day6.zip ren day6.zip day7.zip
if exist day5.zip ren day5.zip day6.zip
if exist day4.zip ren day4.zip day5.zip
if exist day3.zip ren day3.zip day4.zip
if exist day2.zip ren day2.zip day3.zip
if exist day1.zip ren day1.zip day2.zip
:noday1
if exist ..\*.bak attrib +h ..\*.bak
if exist ..\*.zip attrib +h ..\*.zip

if NOT exist c:\temp\nul md c:\temp
pkzip c:\temp\day1.zip ..\*.*
move c:\temp\day1.zip .

if exist ..\*.zip attrib -h ..\*.zip
if exist ..\*.bak attrib -h ..\*.bak
cd ..