So I created MyJar.cmd file, and specified the VM argument:
@echo off
java -jar TractorMapper.jar -Druntime.environment=TEST
both MyJar.cmd and MyJar.jar are saved in C:\sample directory.
Running MyJar.cmd is the problem.
1. If I run it by launching CMD first (Start >> All Programs >> Command
Prompt), then go the C:\sample directory then run MyJar.cmd from the
command prompt, it works ok.
2. If I run it by double-clicking MyJar.cmd from Windows Explorer, it
gives me the exception:
Exception in thread "main" java.util.zip.ZipException: The system
cannot find the file specified
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
What could be the problem?
I've tried displaying the CLASSPATH, in the hopes that in #2, the
CLASSPATH wasn't set. But on both instances, the CLASSPATH is the same.
I'm using Windows XP.
Thanks a lot for your help.
Crash.test.dummy
Did you try right clicking on the CMD file and making sure that the
"current directory" is set properly?
- Oliver
Thanks for your reply.
No, Oliver was not talking about the Location field on the General tab.
That's the directory that contains the file. What you care about is the
"current working directory" when the command runs.
There isn't an easy way to set this. You could do it by creating a
shortcut to the .cmd file, and then setting the property on that.
Better yet, you could specify the full path to the .jar file so that
you're not dependent on the current directory. I'm not familiar enough
with Windows batch scripting to tell you how to do that, but it can't be
too hard... right?
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
> crash.test.dummy <wal...@gmail.com> wrote:
>> Hi Oliver,
>> Are you talking about the Location: field in the General tab? If
>> yes, yes, it is properly set.
>
> No, Oliver was not talking about the Location field on the General tab.
> That's the directory that contains the file. What you care about is the
> "current working directory" when the command runs.
>
> There isn't an easy way to set this. You could do it by creating a
> shortcut to the .cmd file, and then setting the property on that.
>
> Better yet, you could specify the full path to the .jar file so that
> you're not dependent on the current directory. I'm not familiar enough
> with Windows batch scripting to tell you how to do that, but it can't be
> too hard... right?
>
It isn't, but there's a better way. If I understand the OP correctly, the
.cmd file is an unnecessary step. Just create a new shortcut with target
"java -jar TractorMapper.jar -Druntime.environment=TEST" Then right click
the new shortcut, and set the starting directory (in the shortcut tab) to
C:\sample
--
Beware the False Authority Syndrome
Yes, sorry, I thought the OP was working with shortcuts, not Windows
Shell scripts.
The fields I see on the "shortcut" pane when viewing the properties of a
shortcut on Windows XP are:
Target:
Start In:
Shortcut key:
Run:
Comment:
"Target" should contain the command you wish to run and "Start in"
should contain the directory where you want the command to run.
- Oliver
As others have pointed out, this is most probably a problem with the
current directory.
If you always store the .cmd and the .jar file in the same directory you
can use this instead:
java -jar %~dp0%TractorMapper.jar -Druntime.environment=TEST
Which will always use the TractorMapper.jar stored in the same directory
as the .cmd file
Thomas