Clear environment classpath entries

ank5 used Ask the Experts™
I am executing the following Java command from prompt.

java -cp classes;lib\dfc.jar;lib\dfcbase.jar;config; com.WFHistor

I suspect that it is causing some conflict because of the classpath set in environment variables.

I only want the claspath mentioned in the above command to be used. Is there a way to tell it not to use any other classpath entries set in system classpath.

Thank you
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

>>I suspect that it is causing some conflict

Why do you suspect that?
You could always test it by typing


before your Java command. That will unset the classpath, but only in that cmd window (i.e. it doesn't change your system defined environment variable)
Top Expert 2016
If you're giving the classpath explicitly as part of the arguments to java, it will override any previously set classpath. The only other things that could influence the classpath can be unset by the following
java -Djava.endorsed.dirs= -Djava.ext.dirs= -classpath ..........................

Open in new window

Mick BarryJava Developer
Top Expert 2010
> java -cp classes;lib\dfc.jar;lib\dfcbase.jar;config; com.WFHistor

should be fine

other alternative would be to use an executable jar (and include the classpath in the manifest)
Top Expert 2016


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial