Java News Tips Software
Java News Tips Software | Contact | Facebook | Twitter RSS

The input line is too long - Windows command line error

Today I wanted to run the bat file shown below to run a java program. This file is mainly used to set the classpath as you can see below.

@echo off
setlocal

set BROKER_HOME=C:/Documents and Settings/user/workspace/myProject

set CP=%BROKER_HOME%/out/lib/activation-1.0.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/activeio-2.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/axis.jar;%CP%
set CP=%BROKER_HOME%/out/lib/axis.ns.jar;%CP%
set CP=%BROKER_HOME%/out/lib/axis.org.jar;%CP%
set CP=%BROKER_HOME%/out/lib/axis-ant.jar;%CP%
set CP=%BROKER_HOME%/out/lib/connector.jar;%CP%
set CP=%BROKER_HOME%/out/lib/csv.jar;%CP%
set CP=%BROKER_HOME%/out/lib/csvman.jar;%CP%
set CP=%BROKER_HOME%/out/lib/jakarta-oro-2.0.8.jar;%CP%
set CP=%BROKER_HOME%/out/lib/jaxrpc.jar;%CP%
set CP=%BROKER_HOME%/out/lib/jmxri-1.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/jmxtools-1.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/log4j-1.2.8.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mail.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/backport-util-concurrent-3.0.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-beanutils-1.7.0.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-codec-1.3.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-collections-3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-digester-1.7.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-discovery-0.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-httpclient-3.0.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-jxpath-1.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-logging-1.0.4.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-net-1.4.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/commons-pool-1.3.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/dom4j-1.4.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/jug-2.0.0-asl.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-core-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-acegi-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-builders-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-client-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-management-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-ognl-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-pgp-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-scripting-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-spring-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-module-xml-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-ejb-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-email-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-file-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-ftp-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-http-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-jbi-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-jdbc-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-jms-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-multicast-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-quartz-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-rmi-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-soap-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-ssl-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-stream-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-tcp-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-udp-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-vm-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-xfire-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mule-transport-xmpp-1.3.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mx4j-impl-2.1.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mx4j-jmx-2.1.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mx4j-remote-2.1.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/mx4j-tools-2.1.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/ognl-2.6.9.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/xpp3_min-1.1.3.4.O.jar;%CP%
set CP=%BROKER_HOME%/out/lib/mule/xstream-1.2.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/muleOpt/commons-attributes-api-2.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/muleOpt/commons-dbutils-1.0.jar;%CP%
set CP=%BROKER_HOME%/out/lib/muleOpt/commons-io-1.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/muleOpt/commons-lang-2.2.jar;%CP%
set CP=%BROKER_HOME%/out/lib/muleOpt/geronimo-j2ee-connector_1.5_spec-1.0.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/muleOpt/geronimo-jta_1.0.1B_spec-1.0.1.jar;%CP%
set CP=%BROKER_HOME%/out/lib/netsuite-2.0.0.jar;%CP%
set CP=%BROKER_HOME%/out/lib/ojdbc14.jar;%CP%
set CP=%BROKER_HOME%/out/lib/quartz-1.4.0.jar;%CP%
set CP=%BROKER_HOME%/out/lib/saaj.jar;%CP%
set CP=%BROKER_HOME%/out/lib/spring-beans.jar;%CP%
set CP=%BROKER_HOME%/out/lib/spring-context.jar;%CP%
set CP=%BROKER_HOME%/out/lib/spring-core.jar;%CP%
set CP=%BROKER_HOME%/out/lib/wsdl4j-1.5.1.jar;%CP%
set CP=%BROKER_HOME%/out/conf;%CP%
set CP=%BROKER_HOME%/lib/commons-dbutils-1.0.jar;%CP%
set CP=./;%CP%
set CP="%CP%"

ECHO Using Classpath:
ECHO %CP%

cd ..

java -classpath %CP% com.mycompany.myproject.Client

An error message resulted saying "Input line is too long" as shown in the image. This is not an error in the java program which you would guess first.



I have set up a variable for classpath which makes my command too lengthy. This message pops up since the command is too long for the Windows® command line environment to handle.

The number of characters that can be entered into a single command is limited to 8191. (this is including spaces).

For example total number of charaters in the below command is 42.
C:\>javac -classpath myclasses.jar Client.java

There was no solution to the issue other than somehow making the classpath shorter by moving the jar files into a folder like "C:\jars".

Do you have any other solutions for this issue?

Labels:


6 Comments

  1. Anonymous Anonymous on January 11, 2007 7:44 PM  
    You can also temporarily map a drive to the destination jar's directory
  2. unpack all jar files to one directory a set path to this.

    RoVis.
  3. Anonymous Anonymous on January 29, 2009 3:35 AM  
    Maybe the first line of your script should not contain the trailing %CP%

    Otherwise if you run the command from the same cmd.exe window multiple times, you will keep duplicating CP entries...

    Or consider explicitly setting CP to "" initially.

    set CP=
  4. Anonymous Anonymous on August 27, 2009 1:36 AM  
    you tight
  5. Anonymous Anonymous on December 12, 2009 2:47 AM  
    You could use different ClassLoader:
    http://www.cs.put.poznan.pl/dweiss/xml/projects/invoker/index.xml?lang=en
  6. Anonymous Anonymous on December 17, 2009 1:31 PM  
    What if the jar files are dispersed in different directories ?
ABOUT AUTHOR
Page Views :
Email :
PREVIOUS ARTICLES
Select Month:
TOP
Free counter and web stats