1

i am developing a program,for that want to use more than one jar(Example servlet.jar and mysql.jar) i know how to import them in using Eclipse IDE. but not in cmd prompt. Can anybody help me for this thanks in advance...

  • Check-out this http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath – Miko Jul 29 '14 at 06:25

5 Answers5

6

For multiple jars you can do

java -cp "path1/servlet.jar;path2/mysql.jar" yourPackage.Class

Or put all jars in one folder (let it be path1/lib) and do something like following

java -cp "path1/lib/*" yourPackage.Class

Note : classpath wildcards can be used only in Java 6 or later.

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
1

If you want to create a new classpath, write this:

set CLASSPATH=classpath1;

You can see all your classpaths if you type only this:

set

njank
  • 319
  • 3
  • 12
1

ClassPath set through command prompt will work only for current cmd window. Once you close it and open a new cmd window it will not work. Rather than setting classpath from command prompt, keep related paths to system properties:

For windows:

go to My Computer--> Properties--> Advance System Settings--> Environment Variables--> CLASSPATH--> put your path like this--> path1;path2;path3;. Don't forget to keep . (DOT) at the end.

Shailesh Saxena
  • 3,472
  • 2
  • 18
  • 28
1

you can set your class path using cmd prompt like :-

set classpath=(dir of classpath1);(dir of classpath2);(dir of class path3);%CLASSPATH%

Deepanshu J bedi
  • 1,530
  • 1
  • 11
  • 23
0

In enviorment variables , make a new variable named classpath and in value field write as much path you want but seperate them by semicolon.

Ajit Singh
  • 390
  • 4
  • 14