File APIs for Java Developers Manipulate DOC, XLS, PPT, PDF and many others from your application. http://aspose.com/file-tools
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login

# What does @ do, as in: c:\java -classpath % c:\blalba\... A.B.C.Class %@

Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
Im tryig to run the following line in DOS (org. from a shell script):

This results in:
Exception in thread main java.lang.ArrayIndexOutOfBound: 2
at ....
at ....

If I remove the '@' at the end of the line the program doesn't run but says
something like:
"Usage: bla bla bla"

Any ideas?

Could it be, that @ is a unix symbol, and I need the equivalent in DOS?
Ranch Hand

Joined: Aug 16, 2005
Posts: 134
I'm familiar with the -D switch and the -classpath switch, but what are the --jms and --jboss switches for? I can't find any sample code anywhere that uses switches like that.

I apologize for being of no help... that just struck me as an odd usage. I can wage a guess as to the issue you are having though (and I am pretty sure that you have already reached the same conclusion), but it looks to me like there is an error in your code. When you remove the @,the command is not even being executed (thus the usage warning).
Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904

When I include the '@' at the end of "java -Dprogram ..... "
I get the following message:

If '@' is included the application doesn't run, and if I remove it I get an
ArrayIndexOutOfBound exception. I can not access and modify the original
code btw. I just dont know what '@' is... as explained earlier, the line
has been "stolen" from a shell script, and im now trying to get it to work
on DOS.

Any ideas?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19505

42

Originally posted by Svend Rost:
If '@' is included the application doesn't run, and if I remove it I get an
ArrayIndexOutOfBound exception. I can not access and modify the original
code btw. I just dont know what '@' is... as explained earlier, the line
has been "stolen" from a shell script, and im now trying to get it to work
on DOS.

Any ideas?

I don't think that "%@" has any meaning to a DOS command prompt. But if it was from a shellscript, and it was originally "$@", then it is simply the parameters from the shellscript -- the parameters to the shellscript are used to replace the "$@".

Henry

Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
Originally posted by Henry Wong:

I don't think that "%@" has any meaning to a DOS command prompt. But if it was from a shellscript, and it was originally "$@", then it is simply the parameters from the shellscript -- the parameters to the shellscript are used to replace the "$@".

Henry

Yes, it originally was $@ in the shell script (which I then changed to %@ because % is used instead of$ (I've been told)). I dont understand what
your saying at the end? What should I do?

I've been doing a bit of testing. I "stand" in folder c:\foo\bar which
contains a file (Abc.cba) which should be used as input parameter. The application
I need to run (BlahRunner) is located in c:\XX\ (this folder is added to
the my windows classpath btw).

I have a bat file in c:\XX called runner.bar, if it contains:

and I do the following. c:\foo\bar\> runner Abc.cba I get:
Usage:
BlahRunner [--jms|--rmi] <filename>.<extension> [tracefile]

When I look at the output in the DOS window, i.e. what's being executed I
see the following:

If on the other hand I run the bat file without the @, i.e. this is in the
bat file:

I get an exception: ArrayIndexOutOfBounds: 2 BUT when I look at the output
in the dos window it looks like the output I got earlier, i.e. no Abc.cba

Finally I try to insert the file name in the bat file:

and when I run it: c:\foo\bar\> runner
I see that everything seems to gets executed:

But I get an exception: OutOfBoundsException: -1

Anyone got any ideas? when I run the script, i.e. runner.sh Abc.cba
I get the following output in cygwin:
/foo/bar/> java -Dprogram.name=MyProgram -classpath c:\XX\File1;..;c:\XX\FileN A.B.C.BlahRunner Abc.cba --jms --jboss

Svend
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189

34

I believe that the DOS equivalent to \$@ is %1 %2 %3 %4 %5 %6 %7 %8 %9, as in

java -DX=y -cp XXX ClassName --jms --whatever %1 %2 %3 %4 %5 %6 %7 %8 %9

Of course Henry's right about what it does: it expands to all the arguments from the command line of the script. The DOS equivalent just does this explicitly for the first 9 parameters.

Note, for those that may not have caught on, that --jms and --whatever are command-line arguments to the class, not to Java itself.

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19505

42

Another option is to use "%*" which expands to all of the parameters.

BTW, the DOS command prompt is actually really cool -- in terms of parameter handling, that is. You can actually asked DOS to treat the parameter as a file and replace it with related data instead.

Henry

I agree. Here's the link: http://aspose.com/file-tools

subject: What does @ do, as in: c:\java -classpath % c:\blalba\... A.B.C.Class %@