Link to home
Start Free TrialLog in
Avatar of krishnasaikarthik
krishnasaikarthik

asked on

How to Set Java Classpath Size

Dear Experts

Our application classapth contains 100 jar files.

I am running my application by setting the classpath as:

set classpath=jar1;jar2;jar3;..................;jar100;

then its giving the error as :

F:\Working\Source\EHR\developmentend\EHR\bin>set CLASSPATH=F:\Working\Source\EHR\developmentend\EHR\lib\physical.jar;F:\Working\Source\EHR\developmentend\EHR\lib\proc_diag_codes.jar;F:\Working\Source\EHR\developmentend\EHR\lib\vitalsigns.jar;F:\Working\Source\EHR\developmentend\EHR\lib\lab_res.jar;F:\Working\Source\EHR\developmentend\EHR\lib\level_service.jar;F:\Working\Source\EHR\developmentend\EHR\lib\maps.jar;F:\Working\Source\EHR\developmentend\EHR\lib\control.jar;F:\Working\Source\EHR\devel
opmentend\EHR\lib\hi_att.jar;F:\Working\Source\EHR\developmentend\EHR\lib\insu.jar;F:\Working\Source\EHR\developmentend\EHR\lib\avalon-framework-cvs-20020806.jar;F:\Working\Source\EHR\developmentend\EHR\bin;F:\Working\Source\EHR\developmentend\EHR\lib\batik-util.jar;F:\Working\Source\EHR\developmentend\EHR\lib\batik.jar;F:\Working\Source\EHR\developmentend\EHR\lib\xercesImpl.jar;F:\Working\Source\EHR\developmentend\EHR\lib\xmlParserAPIs.jar;F:\Working\Source\EHR\developmentend\EHR\lib\batik-awt-
util.jar;F:\Working\Source\EHR\developmentend\EHR\lib\xml4j.jar;F:\Working\Source\EHR\developmentend\EHR\lib\jai_codec.jar;F:\Working\Source\EHR\developmentend\EHR\lib\jai_core.jar;F:\Working\Source\EHR\developmentend\EHR\lib\xalan.jar;F:\Working\Source\EHR\developmentend\EHR\lib\common_util.jar;F:\Working\Source\EHR\developmentend\EHR\lib\middleware_fdb.jar;F:\Working\Source\EHR\developmentend\EHR\lib\components_iui_label.jar;F:\Working\Source\EHR\developmentend\EHR\lib\images.jar;F:\Working\So
urce\EHR\developmentend\EHR\lib\CommonClasses.jar;F:\Working\Source\EHR\developmentend\EHR\lib\cryptix.jar;F:\Working\Source\EHR\developmentend\EHR\lib\resources.jar;F:\Working\Source\EHR\developmentend\EHR\lib\sgml.jar;F:\Working\Source\EHR\developmentend\EHR\lib\CommunicationClasses.jar;F:\Working\Source\EHR\developmentend\EHR\lib\itrust.jar;F:\Working\Source\EHR\developmentend\EHR\lib\settings.jar;F:\Working\Source\EHR\developmentend\EHR\lib\ReadMeProps.jar;

The input line is too long.

-------------------
its giving the above error and its not starting our application.
i heared that in java default classpath size is 2KB.

how can i set my own classpath size?

is there any way ?

thanks
km
Avatar of avinthm
avinthm

create another jar file which will contain all your jar files.
include that in your path.

cheers
Avatar of Mayank S
>> i heared that in java default classpath size is 2KB.

Not sure, it might also depend on the OS. Try setting the class-path in pieces. Like add 5 JARs to it, then again next 5, and so on. See if it works. Make sure you use "" to enclose the file-path if it contains blank spaces.
Avatar of krishnasaikarthik

ASKER

hello

if i placed all jars in one jar file, then i am getting the

Exception in thread "main" java.lang.NoClassDefFoundError: com/itrust/ariel/client/Logon

thanks
km

try something like this:
SET MY_APP_PATH=
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\oracle.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\nlscharset12.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\jtds.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\mysql.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\postgresql.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\jconnect45.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\db2jcc.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\db2jcc_license_cu.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\db2java.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\ifxjdbc.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\jconnect55.jar

SET MY_APP_PATH=%MY_APP_PATH%;.\lib\xmlparserv2.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\xdb.jar

SET MY_APP_PATH=%MY_APP_PATH%;.\lib\mail.jar
SET MY_APP_PATH=%MY_APP_PATH%;.\lib\activation.jar

java -cp "%MY_APP_PATH%" com.MyApp
 

create a bat script.....
dear mayankeagle,

i changed the classpath as:

set CLASSPATH=%APP_HOME%\lib\itrust.jar;%APP_HOME%\lib\settings.jar;%APP_HOME%\lib\ReadMeProps.jar;

set CLASSPATH=%APP_HOME%\lib\resources.jar;%APP_HOME%\lib\sgml.jar;%APP_HOME%\lib\CommunicationClasses.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\images.jar;%APP_HOME%\lib\CommonClasses.jar;%APP_HOME%\lib\cryptix.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\common_util.jar;%APP_HOME%\lib\middleware_fdb.jar;%APP_HOME%\lib\components_iui_label.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\xml4j.jar;%APP_HOME%\lib\jai_codec.jar;%APP_HOME%\lib\jai_core.jar;%APP_HOME%\lib\xalan.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\xercesImpl.jar;%APP_HOME%\lib\xmlParserAPIs.jar;%APP_HOME%\lib\batik-awt-util.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\batik-util.jar;%APP_HOME%\lib\batik.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\avalon-framework-cvs-20020806.jar;%APP_HOME%\bin;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\control.jar;%APP_HOME%\lib\hi_att.jar;%APP_HOME%\lib\insu.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\lab_res.jar;%APP_HOME%\lib\level_service.jar;%APP_HOME%\lib\maps.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\physical.jar;%APP_HOME%\lib\proc_diag_codes.jar;%APP_HOME%\lib\vitalsigns.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\LabTests.jar;%APP_HOME%\lib\jRegistryKey.jar;%APP_HOME%\lib\CAG_lib.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\fop.jar;%APP_HOME%\lib\itrustpdf.jar;%APP_HOME%\lib\PDF_Classes.jar;%CLASSPATH%

set CLASSPATH=%APP_HOME%\lib\itext-1.2.jar;%APP_HOME%\lib\jRegistryKey.jar;%CLASSPATH%


still i am getting the same problem.

i am working on Windows2000.
i think in windows the default classpath size is 2kb.
am i right?

how can i set my classpath size?

thanks
km
Dear el_dios

i created the batch script as, but i am getting the same problem.....

@echo on
set APP_HOME=F:\Working\Source\EHR\developmentend\EHR
set JAVA_HOME=C:\Program Files\Java\j2re1.4.2_10
set path=%APP_HOME%\bin;%JAVA_HOME%\bin;

set MYAPPPATH=
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\itrust.jar;%APP_HOME%\lib\settings.jar;%APP_HOME%\lib\ReadMeProps.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\resources.jar;%APP_HOME%\lib\sgml.jar;%APP_HOME%\lib\CommunicationClasses.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\images.jar;%APP_HOME%\lib\CommonClasses.jar;%APP_HOME%\lib\cryptix.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\common_util.jar;%APP_HOME%\lib\middleware_fdb.jar;%APP_HOME%\lib\components_iui_label.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\xml4j.jar;%APP_HOME%\lib\jai_codec.jar;%APP_HOME%\lib\jai_core.jar;%APP_HOME%\lib\xalan.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\xercesImpl.jar;%APP_HOME%\lib\xmlParserAPIs.jar;%APP_HOME%\lib\batik-awt-util.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\batik-util.jar;%APP_HOME%\lib\batik.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\avalon-framework-cvs-20020806.jar;%APP_HOME%\bin;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\control.jar;%APP_HOME%\lib\hi_att.jar;%APP_HOME%\lib\insu.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\lab_res.jar;%APP_HOME%\lib\level_service.jar;%APP_HOME%\lib\maps.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\physical.jar;%APP_HOME%\lib\proc_diag_codes.jar;%APP_HOME%\lib\vitalsigns.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\LabTests.jar;%APP_HOME%\lib\jRegistryKey.jar;%APP_HOME%\lib\CAG_lib.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\fop.jar;%APP_HOME%\lib\itrustpdf.jar;%APP_HOME%\lib\PDF_Classes.jar;
set MYAPPPATH=%MYAPPPATH%;%APP_HOME%\lib\itext-1.2.jar;%APP_HOME%\lib\jRegistryKey.jar;

java -mx200m  -cp "%MYAPPPATH%" -Djava.library.path=%APP_HOME%\bin -Dcom.itrust.ariel.datamanager.file="file:///c:/Medplexus/EHR/lib/ariel.properties" -Dcom.itrust.ariel.client.home=C:/Medplexus/EHR  -Dmedplexus.system.copy.home=C:/MedPlexus -Dcom.itrust.ariel.sgml.controlfile="file:///C:/Medplexus/EHR/lib/sgml_role.properties" -Dcom.itrust.ariel.sgml.admin.controlfile="file:///C:/Medplexus/EHR/lib/sgml_admin.properties" com.itrust.ariel.client.Logon


thanks
km

create a jar file including all the jar files, except the one with main method (which contains the class com.itrust.ariel.client.Logon).
now specify the path of two jar files in you class path.

still i am getting the classpath not found error.

why it is,

in all our code i am importing other classes which are in some other package.

import com.test.pack1;

so, the jar must include the package structure (com.test.pack1)

trhanks
km
the problem might be.....jvm might search for classes in all the jar files that are in the class path.
but i m not sure whether the jar files within the jar file are searched for required classes.

one think u can do is - extract all the jar files and then create a jar file.
So now, the new jar file will contain classes directly inside of being in another jar.

you can achive this by writing a simple ant script.
here is the documentation on how to use ant
http://ant.apache.org/manual/index.html
> extract all the jar files and then create a jar file.
i will make this sentence more clear.
extract all the classes within all the jar files in a temp folder.
then create a jar file of all these classes
1) When you were asked to create a single jar with all class files you must actually maintain the same directory structure. Not sure if you actually unjarred all files to a folder and then jarred it back again?
2) Also when you get such a big error, saying application doesnt start up, can you print exact output of the command line. I once had a classpath which was like 2 pages long in Windows and it still used to work.
dear avintham,

i should maintain 100 jars separately.

is there any way to set the classpath size?

thanks
km.
put the jars in the jre's ext directory
then u won't need to include them in the classpath, they'll get found automatically
> is there any way to set the classpath size?
i guess NO
yes objects,

i know about that.

is there any way in windows to set the classpath size?

thanks
km
>> set CLASSPATH=%APP_HOME%\lib\itrust.jar;%APP_HOME%\lib\settings.jar;%APP_HOME%\lib\ReadMeProps.jar;

Did you put all of them in a batch-file and tried to run them? Try to run those commands one by one on the command-prompt.
yes you need to increase the environemt space
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thats the same as using the ext directory. Questions about setting the classpath.
>>Thats the same as using the ext directory.

No it isn't ;-)
in fact all it does it just define another ext directory.
Precisely. That's why it's not the same
ROTFL, whatever u say :-D
krishnasaikarthik, if you need more info about the differences under 'discussion', let me know
:-)
I stated above u could put them in an ext directory and they'd get picked up automatically.
And u said you knew about that??
dear objects,

yes,

but i am not interested to place all the jar files in the JRE's ext directory.

i am interested to place them in our own directory & setting that directory as an ext directory.

thanks
km
you can have an ext directory wherever you want :)