Setting Java classpath option with spaces and quotes under Windows®

Java provides two methods for setting paths of the classes. 1. Set the command line option classpath 2. Set the CLASSPATH environment variab...

Java provides two methods for setting paths of the classes.
1. Set the command line option classpath
2. Set the CLASSPATH environment variable

The second option is easy, but has a draw back as a common CLASSPATH is shared within all the projects and classes, which makes it harder to test different projects with different classes.

So the first option is the prefered way. It is used as;
java -classpath first.jar;second.jar TestClient


When the paths to the jar files have spaces, the command line classpath option causes errors. Under Windows installation like 2000/NT/XP, all the users get a folder with the user name under a folder named "Documents and Settings" (which has a space). And if the jar files are under the user folder, path would look like "C:/Documents and Settings/someUser/.." which would cause the above error.

How to over come this issue
1. Put quotes and group the whole class path
java -classpath "C:/Documents and Settings/user/project/lib/axis.jar; C:/Documents and Settings/user/project/lib/axis-ant.jar;" TestClient

2. Put quotes on individual paths
java -classpath "C:/Documents and Settings/user/project/lib/axis.jar"; "C:/Documents and Settings/user/project/lib/axis-ant.jar;" TestClient

COMMENTS

BLOGGER: 5
Loading...
Name

About,8,Adsense,3,Ant,1,Apache,2,Axis,3,Database,2,Earn Online,3,Eclipse,8,Firefox,9,Google,27,GWT,8,Hardware,3,IE,1,Internet,1,Java,48,Javascript,8,Jenkins,1,Linux,6,Miscellaneous,18,News,46,Opinion,9,PHP,1,Productivity,3,Puzzle,3,Security,3,Software,25,Sports,9,Spring,2,TDD,4,Tech,87,Tips,18,Tomcat,5,Tools,19,Tutorial,13,Ubuntu,4,Web application,12,Web Design,2,Web services,4,Windows,3,
ltr
item
digizolm12: Setting Java classpath option with spaces and quotes under Windows®
Setting Java classpath option with spaces and quotes under Windows®
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA6bYVVcpG8M5DEA7n_7cO1R7csqhOh_SvRkvnyII5yqYoOHp1rWDWBFefswP1U0CxSWyeG_Cfp3FjKxeUTq0W9ICL1iCJ3Nl9xw81jRH9HpkFl0J7kL4bsd3rerZKuJink6ic3iIFxY7U/s400/classpath.bmp
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA6bYVVcpG8M5DEA7n_7cO1R7csqhOh_SvRkvnyII5yqYoOHp1rWDWBFefswP1U0CxSWyeG_Cfp3FjKxeUTq0W9ICL1iCJ3Nl9xw81jRH9HpkFl0J7kL4bsd3rerZKuJink6ic3iIFxY7U/s72-c/classpath.bmp
digizolm12
https://digizolm12.blogspot.com/2006/12/setting-java-classpath-option-with.html
https://digizolm12.blogspot.com/
http://digizolm12.blogspot.com/
http://digizolm12.blogspot.com/2006/12/setting-java-classpath-option-with.html
true
1218430210337039745
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy