Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Command Prompt Environment (Command Size)

10 views
Skip to first unread message

Steve

unread,
Oct 10, 2001, 2:12:01 PM10/10/01
to
I'm trying to run a java program from the Command Prompt
command line. The problem is that by the time I'd done
with ten or so -D options and then specify the Java class
to execute, the command interpretter acts as if it doesn't
see the Java class name.

I suspect the command line is so long that it is getting
truncated somewhere along the way. How do I find the
current command line size in my Command Prompt windows?
And then how do I adjust it to make it longer?

Windows should really make it much easier and more
intuitive to control such environment settings.

Thanks,
Steve

A l e x A n g e l o p o u l o s

unread,
Oct 10, 2001, 2:22:15 PM10/10/01
to
Yes, it should be easier...

If you're running Win2k, I believe the command line is limited to 127
characters. Another problem you may have is if your command line executable
is actually a batch file, it might not correctly see more than 9 options.

Verify that it's a traditional exe and not a script ending with BAT or CMD
that you use as the %0 argument.

I would also suggest this as a quick check (it won't work if you an
argument-limited EXE): try writing your entire command line to a file, then
running that as a batch file.

If that doesn't work, post a typical command line and there are a couple of
other possible workarounds to try; I'd want to see it before giving an
example due to the typical issues with special characters that CMD has.

"Steve" <saf...@cominsights.com> wrote in message
news:3dae01c151b7$0efab160$a5e62ecf@tkmsftngxa07...

Star Fleet Admiral Q

unread,
Oct 10, 2001, 11:18:52 PM10/10/01
to
The "Physical" Command Line may be limited to 127 or 255 (I'm not sure), but
it can be Virtually lengthened by the use of variables used in place of
pathnames.

--
Star Fleet Admiral "Q"
"Q" Continuum

Just somebody who likes to help,
no MVP, MCP, MCSE, etc....

Remove the Obvious from E-Mail to reply directly:
email: doomsdayma...@startrekmail.com

"Steve" <saf...@cominsights.com> wrote in message
news:3dae01c151b7$0efab160$a5e62ecf@tkmsftngxa07...

A l e x A n g e l o p o u l o s

unread,
Oct 11, 2001, 10:18:27 AM10/11/01
to

"Star Fleet Admiral Q" <doomsdayma...@startrekmail.com> wrote in
message news:#edQCOgUBHA.1848@tkmsftngp03...

> The "Physical" Command Line may be limited to 127 or 255 (I'm not sure),
but
> it can be Virtually lengthened by the use of variables used in place of
> pathnames.
>
LOL - I couldn't remember which it was either!

I didn't want to necessarily say anything about the variable subs without
seeing the actual command line; if he has paths with spacesI there could be
some fallout during recursive substitution and expansion...


Star Fleet Admiral Q

unread,
Oct 11, 2001, 1:39:10 PM10/11/01
to
Yes, I've had this happen several times and have to work around it
accordingly - it seems you need some type of general will always work type
of syntax of which I've been searching for but haven't located as of yet.

--
Star Fleet Admiral "Q"
"Q" Continuum

Just somebody who likes to help,
no MVP, MCP, MCSE, etc....

Remove the Obvious from E-Mail to reply directly:
email: doomsdayma...@startrekmail.com

"A l e x A n g e l o p o u l o s" <first name plus last name and I'm at
hotmail; figure it out> wrote in message
news:#$Vch#lUBHA.1400@tkmsftngp03...

A l e x A n g e l o p o u l o s

unread,
Oct 11, 2001, 2:39:16 PM10/11/01
to

"Star Fleet Admiral Q" <doomsdayma...@startrekmail.com> wrote in
message news:#NdFxunUBHA.1976@tkmsftngp07...

> Yes, I've had this happen several times and have to work around it
> accordingly - it seems you need some type of general will always work type
> of syntax of which I've been searching for but haven't located as of yet.
Ain't there...

Supposedly you can use ! delimiters instead of % in XP and this will delay
expansion until run time, preventing a whole host of those problems; can't
speak from experience since I haven't worked with it yet.


Marty List

unread,
Oct 11, 2001, 3:38:34 PM10/11/01
to

Delayed environment variable expansion was introduced in 2000, not XP.
Check out Set /?

"A l e x A n g e l o p o u l o s" <first name plus last name and I'm at
hotmail; figure it out> wrote in message

news:OEc0fRoUBHA.1384@tkmsftngp03...

Star Fleet Admiral Q

unread,
Oct 11, 2001, 9:23:33 PM10/11/01
to
It appears that yes it was, using the /v option on the execution of CMD.EXE
will delay this until execution time.

--
Star Fleet Admiral "Q"
"Q" Continuum

Just somebody who likes to help,
no MVP, MCP, MCSE, etc....

Remove the Obvious from E-Mail to reply directly:
email: doomsdayma...@startrekmail.com

"Marty List" <Bill....@sun.com> wrote in message
news:#NUYsxoUBHA.2116@tkmsftngp03...

A l e x A n g e l o p o u l o s

unread,
Oct 12, 2001, 10:32:41 AM10/12/01
to

"Marty List" <Bill....@sun.com> wrote in message
news:#NUYsxoUBHA.2116@tkmsftngp03...
>
> Delayed environment variable expansion was introduced in 2000, not XP.
> Check out Set /?

Whoops - my bad...

That's what happens when you "skip" intermediate versions while comparing
comands...


Jonathan de Boyne Pollard

unread,
Oct 13, 2001, 9:23:17 AM10/13/01
to
S> I suspect the command line is so long that it is getting
S> truncated somewhere along the way. How do I find the
S> current command line size in my Command Prompt windows?
S> And then how do I adjust it to make it longer?
S>
S> Windows should really make it much easier and more
S> intuitive to control such environment settings.

There *is no* environment setting to be controlled.

Command line length is subject to two factors: the length of the command tail
that the operating system supports passing to applications, and the length of
the command line that the command interpreter supports dealing with in the
first place.

DOS-Windows 95/98 and DOS-Windows ME, being DOS-based, have the same operating
system limits on command tail as DOS does, namely 126 characters. DOS-Windows
users who want longer command tails have no choice but to switch to a better
operating system. Fortunately, this newsgroup is not about DOS-Windows. (-:

Windows NT 4, Windows NT 2000, and Windows NT XP all, according to my
information, have an operating system limit of 32KiB on command tail length.
Long before you hit this limit, however, you will hit the limits imposed by
the various command interpreters. Command interpreters impose draconian
limitations of their own, for no good reason, even though the underlying
operating system is in fact quite generous.

Microsoft's CMD has a hardwired limit on the length of a command line that can
be entered of 2046 characters. So, too, does the CMD from ReactOS. JP
Software's 4NT has a limit of 1023 characters. This limit isn't modifiable in
any of them. (Unless one counts altering the source for the ReactOS CMD and
then recompiling it as "modifiable".)

There's no need for 32-bit command interpreters to have any such line length
limits at all, of course. They are only imposed because the authors of these
command interpreters failed to learn from past experience and used
fixed-length buffers for input handling and processing of command lines. It
is, however, quite possible to write a command interpreter that doesn't use
fixed-length buffers, and thus is limited only by available heap space and the
limits imposed by the underlying operating system. None of Microsoft, JP
Software, or the ReactOS developers have seen fit to do so, though.

Jonathan de Boyne Pollard

unread,
Oct 13, 2001, 9:23:35 AM10/13/01
to
AA> If you're running Win2k, I believe the command line is limited
AA> to 127 characters. [...]

This is the DOS-Windows 95/98/ME limit. The Windows NT 4/2000/XP limit is
32KiB.

A l e x A n g e l o p o u l o s

unread,
Oct 13, 2001, 1:20:06 PM10/13/01
to
FAQ Material....

"Jonathan de Boyne Pollard" <J.deBoyn...@tesco.net> wrote in message
news:3BC84045...@tesco.net...

> There *is no* environment setting to be controlled.

....


Marty List

unread,
Oct 14, 2001, 1:16:17 PM10/14/01
to

Regardless of what the theoretical limit for a command line is, CMD.EXE will
only recognize 259 characters.


"Jonathan de Boyne Pollard" <J.deBoyn...@tesco.net> wrote in message

news:3BC84057...@tesco.net...

Marty List

unread,
Oct 14, 2001, 1:28:37 PM10/14/01
to

Wooops, I was talking on the phone and hit send prematurely.

Regardless of what the theoretical limit for a command line is, CMD.EXE will

only recognize 259 characters for the program name or first parameter, and
up to 2046 characters for the entire command line.


"Marty List" <Bill....@sun.com> wrote in message

news:ecHk3PNVBHA.1632@tkmsftngp05...

A l e x A n g e l o p o u l o s

unread,
Oct 14, 2001, 1:31:33 PM10/14/01
to
So what are the practical limits for these 2 situations?

(1) Directly typing a command line followed by enter, no expansions
involved: is it correct to say 259 characters?


(2) A command line which involves some variables being expanded out, such as
in a script - same 259 or would it be the longer 2048 limit?


"Marty List" <Bill....@sun.com> wrote in message
news:ecHk3PNVBHA.1632@tkmsftngp05...
>

Steve

unread,
Oct 15, 2001, 2:21:30 AM10/15/01
to
Jonathan,

Thanks for a very thorough response. Now I suspect that I
am seeing a problem with my command tail, although it
seems to fit in the size parameters you mentioned.

BTW, I don't have this problem at all on my Windows
Professional 2000 workstation. This is a new problem only
on my new Windows Server 2000 machine (a Dell PowerEdge
2500). My Windows Professional 2000 workstation command
line handles my code execution just fine as expected.

Is there a difference in the CMD between Windows 2000
Professional and Windows 2000 Server?

Anyway, for the much more detailed version of what's going
on, I used Microsoft Word to measure the number of
characters as 605 (with spaces included in the count).
The command is actually as follows:

C:\jdk1.3\bin\java.exe -Dserver.name="adminserver" -
Dsun.jws.javachome="C:\jdk1.3" -
Dserver.root="C:\JavaWebServer2.0" -
Duser.keystore="C:\JavaWebServer2.0\keys" -
Dpath="C:\WINNT\system32;C:\WINNT;C:\WINNT\System32
\Wbem;.;C:\jdk1.3\bin;C:\Program Files\Common
Files\Network Associates\VirusScan Engine\4.0.xx\" -
Djavahome="C:\jdk1.3" -Dwindir="C:\WINNT" -
Duser.trusted_CA_certs="C:\JavaWebServer2.0\CAstore" -
Dserver.verbose -Dnojre=true -
Djava.security.policy=file:\\C:\JavaWebServer2.0
\security\jserv.policy -
Djserv.security.manager=com.sun.server.security.ServletSecu
rity12 com.sun.server.ServerProcess

The error I'm receiving at this time is as follows:

Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] jarfile [args...]
(to execute a jar file)

where options include:
-cp -classpath <directories and zip/jar files
separated by ;>
set search path for application classes
and resources
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -help print this help message
-X print help on non-standard options

This indicates two things:

(1) The Java Virtual Machine (JVM) is being properly
executed as expected from the "C:\jdk1.3\bin\java.exe"
portion of the command line, and

(2) The classname com.sun.server.ServerProcess is not
getting fed as a parameter into the JVM process.

I know this because if the classname was being fed
properly into the JVM, then either the application would
start executing, or else I would see an error. If my
problem was with the CLASSPATH, then the error would look
like:

Exception in thread "main" java.lang.NoClassDefFoundError:
com/sun/server/ServerProcess

However, since I'm not seeing that error, but rather I'm
seeing an error that indicates that NO classname is
being "seen" by the JVM, that indicates to me that the
command tail that you mentioned is not working properly.

Are there parameters or other ways to adjust the command
tail? Thanks to everyone who's responded on this subject
so far.

Any help anyone can offer me to get my java.exe process to
see the "com.sun.server.ServerProcess" parameter will be
most helpful to me at this point.

Thanks,
Steve

>.
>

Jonathan de Boyne Pollard

unread,
Oct 17, 2001, 4:38:16 AM10/17/01
to
S> BTW, I don't have this problem at all on my Windows
S> Professional 2000 workstation. This is a new problem only
S> on my new Windows Server 2000 machine [...]
S> Is there a difference in the CMD between Windows 2000
S> Professional and Windows 2000 Server?

I don't know. It seems unlikely, however.

S> The command is actually as follows:

You need to determine how much of that command tail is reaching the process.
Substitute "ECHO", or "%SystemRoot%\System32\CMD.EXE /C ECHO" for
"C:\jdk1.3\bin\java.exe" and try the command line again.

You will very probably find that the entire line is echoed back, implying that
there is no problem with the command line length whatsoever.

Indeed, you will very probably find that truncation of the command line was
never your problem at all, and that your problem was actually that you had

-Dpath="C:\WINNT\system32;C:\WINNT;C:\WINNT\System32


\Wbem;.;C:\jdk1.3\bin;C:\Program Files\Common
Files\Network Associates\VirusScan Engine\4.0.xx\"

where you should have had

-Dpath="C:\WINNT\system32;C:\WINNT;C:\WINNT\System32


\Wbem;.;C:\jdk1.3\bin;C:\Program Files\Common
Files\Network Associates\VirusScan Engine\4.0.xx"

(-:

Jonathan de Boyne Pollard

unread,
Oct 17, 2001, 4:39:22 AM10/17/01
to
AA> So what are the practical limits for these 2 situations?
AA> (1) Directly typing a command line followed by enter, no
AA> expansions involved: is it correct to say 259 characters?

2046 characters is the limit that Microsoft's CMD imposes on the size of the
command line that can be entered interactively. The CMD from ReactOS imposes
the same limit. JP Software's 4NT imposes a limit of 1023 characters in
versions prior to version 4, and 2047 characters in version 4 and later.
(This updates what I said previously, by the way.)

AA> (2) A command line which involves some variables being expanded
AA> out, such as in a script - same 259 or would it be the longer
AA> 2048 limit?

The documented limit imposed by JP Software's 4NT on the total length of a
command line after variable, alias, and function expansion is 4095
characters. The corresponding limits for Microsoft's CMD and the ReactOS CMD
are not documented, and I have not performed any experiments to determine
them.

The limits on the command name portion of a command line are less interesting,
but (as the subject has arisen) here they are anyway: JP Software's 4NT
quietly truncates the command name portion of a command line when it exceeds
260 characters. Microsoft's CMD complains with an error message unless the
command name portion of a command line is 259 characters or less. The ReactOS
CMD crashes if the command name portion of a command line exceeds 233
characters.

0 new messages