473,796 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Starting Java program from Win CDROM

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:\a b
set AB_DATA_DIR=D:\ ab\data
set AB_MEM_MAX=200m

cd %AB_JAR_DIR%
java -Xmx%AB_MEM_MAX% -Ddatapath=%AB_D ATA_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
2 2776
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*******@hotm ail.com> wrote in message
news:4c******** *************** ***@posting.goo gle.com...
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:\a b
set AB_DATA_DIR=D:\ ab\data
set AB_MEM_MAX=200m

cd %AB_JAR_DIR%
java -Xmx%AB_MEM_MAX% -Ddatapath=%AB_D ATA_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
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:\a b
set AB_DATA_DIR=D:\ ab\data
set AB_MEM_MAX=200m

cd %AB_JAR_DIR%
java -Xmx%AB_MEM_MAX% -Ddatapath=%AB_D ATA_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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1506
by: Silvio Goluboviæ | last post by:
I have a problem with my CDROM. It reads only original cd.
13
4453
by: Ash | last post by:
Hey. Im new to Java, and am having a prroblem with the netbeans IDE. every time i try to import java.awt.* , I can't use any of the methods(like they don't exist). I can compile it fine, but when I try to run it, I get "exception in class main". Can anyone help me, please?
2
3185
by: Micke | last post by:
I have problems with this simple program below. It starts to read and dump wav data to file but stops after 2MB. The cdda2wav processes are still alive but nothing more is happening. I have more advanced examples with threads and reading from the process buffers but the result is the same. Java version is 1.5 and OS is Linux slackware 10.0. public class TestRead { public static void main (String args) { try {
1
3089
by: Robert | last post by:
I am reading this book - Java Unleashed - However I cannot get the programs on the CD because the CDrom no longer works. I am just wondering if anyone has the CDrom available and can send me a copy of the source code for the programs. If you do, you can send me to my google account drpanli@gmail.com and it will be able to receive large email files. Thanks all in advance.
9
37211
by: Paul Steele | last post by:
I am writing a C# app that needs to periodically poll for cdroms and usb storage device insertions. I've looked at the WMI functions but haven't found anything all that useful. The closest is Win32_DiskDrive, but it doesn't seem to return any information on cdrom devices. I suspect there might be a Win32 API call, but I haven't found any info yet using Google. Is there a way to achieve this in C#?
1
9657
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
6
2440
by: AOECheatmaster | last post by:
I am trying to write a C++ autorun launcher, but i have a problem, i cannot figure out how to set the buttons to launch the apps to use whatever drive number the CDROM is located at, all i can think of is to have it default to D:\, but then it won't work on most computers!!! Please help!!!
3
9066
by: Ognjen Bezanov | last post by:
Hello, I am trying to control a CD-ROM drive using python. The code I use is shown below.
14
4496
by: Keith McCutcheon | last post by:
I've got a jar file that I'm loading with Java's Web Start. When I load the ..jnlp file from a browser, the application installs and runs properly the first time. If I close the application and click on the link in the browser a second time, the Web Start splash screen loads for 15-20 seconds and disappears without launching the app. If I delete the application from the Web Start utility it will again download and execute the first time...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.