Hello,
I am a pure Linux guy. I wrote a Java program that is going to be used
by some Windows people, and I wish the startup of the program to be as
simple as possible, namely to double-click on the icon of a BAT script
on the CDROM. The program accesses files in a directory which path is
given as an argument on the command line. The script I have now is the
following:
--- start of script ---
set AB_JAR_DIR=D:\ab
set AB_DATA_DIR=D:\ab\data
set AB_MEM_MAX=200m
cd %AB_JAR_DIR%
java -Xmx%AB_MEM_MAX% -Ddatapath=%AB_DATA_DIR% -jar ab-0.1.3.jar
--- end of script ---
Unfortunately I know that there are people around who have their CDROM
attached to another drive letter than D:, which would prevent that
script to be executed properly. Thus the question:
How do I find the drive letter of the CDROM the script was started
from, and how do I use it in the script ?
Is there a simpler way to to that ?
Thanks in advance.
Disclaimer: I didn't find any active comp.*.dos.* newsgroup to post
that question and I am fully aware of the fact this might not be the
ideal place to ask that question, but I am sure there are other
DOS-illiterate Java programmers (like me) around for whom the answers
might be useful too.
Alex Molochnikov - 11 Mar 2005 04:39 GMT
This may not answer your original question, but before worrying about the CD
drive, how are you going to run your Java program? I mean, do you realize
that in the world of Windows, many (actually, most) of the users don't have
the JVM on their desktops, and the majority of them never heard of Java?
There are packaging products that bundle the application classes and JAR
files with JRE, and you may want to explore this route. In this case, you
will not need the BAT script.
Alex Molochnikov
Gestalt Corporation
> Hello,
>
[quoted text clipped - 32 lines]
> DOS-illiterate Java programmers (like me) around for whom the answers
> might be useful too.
Raymond DeCampo - 11 Mar 2005 12:16 GMT
> Hello,
>
[quoted text clipped - 24 lines]
>
> Is there a simpler way to to that ?
First, it is probably unnecessary. When a user double-clicks a BAT file
in Windows, the DOS shell is started in the directory of the BAT file.
So you could safely use relative directories, or directories without the
drive letter (e.g. \ab\data).
Second, if you find you need it after all, the DOS shell provides some
magic incantations to get the drive, path, etc. of any file, including
the currently running script. These have the form %~dp0 and such. To
get the exact syntax, go to your Windows machine and go to Windows help
(Windows key + F1 or Start -> Help). Go to '%' in the index.
HTH,
Ray

Signature
XML is the programmer's duct tape.