By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,932 Members | 1,455 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,932 IT Pros & Developers. It's quick & easy.

Starting Java program from Win CDROM

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"enclume42" <en*******@hotmail.com> wrote in message
news:4c**************************@posting.google.c om...
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.

Jul 17 '05 #2

P: n/a
enclume42 wrote:
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 ?


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
--
XML is the programmer's duct tape.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.