ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rhino" <>
Subject Re: Basic Questions about Classpath
Date Wed, 14 Jul 2004 19:07:19 GMT
I agree with you; it makes more sense to set the classpath explicitly for a
given process than to rely on what might be in the CLASSPATH environment
variable. I got away with using the environment variable in XP but it was
more by luck than skill.

That's why I started trying to supply it explicitly via a classpath
attribute on the Win2000 machine. Unfortunately, that didn't seem to help;
even when I had the CLASSPATH environment variable and the classpath
attribute set to the correct paths, the <java> task used the path to the
executable jar alone, ignoring both the environment variable and the
attribute. My note was trying to confirm that Ant should be using the
classpath attribute if it was set and use the CLASSPATH environment variable
if the attribute was not set. You have confirmed that this is what should

Now I have to figure out why it isn't happening. So far, I can't think of a
good reason for this weird behaviour. The CLASSPATH env. var. was set to the
correct values on the Win2000 machine and this was confirmed via 'echo
%CLASSPATH%' at the command line. The CLASSPATH env. var. is a global/system
env. var., not a user env. var., as confirmed in the Control Panel and there
is no user CLASSPATH variable to override the global env. var. We will have
to try deleting the CLASSPATH env. var. while specifying it within Ant and
see if that fixes the problem.

I've already run the Ant script with the -debug and -v flags on and it
confirms that the CLASSPATH matches the CLASSPATH env. var. which just
deepens the mystery and adds to the frustration; the program continues to
fail because it can't see my JDBC driver, even though it is in the

Can you (or anyone else) tell me how to run "Ant diagnostics"? I'm not aware
of any diagnostics beyond the -v and -debug fields? I can't find anything
about diagnostics in the manual either.


----- Original Message ----- 
From: "Doug Lochart" <>
To: "Ant Users List" <>
Sent: Wednesday, July 14, 2004 11:32 AM
Subject: Re: Basic Questions about Classpath

1.  This is my understaning.  I looked into the CommandLineJava source file
of ant and it looks as if this is the case
2.  Again this is correct to my understanding.

First of all I never rely on or specifically set a CLASSPATH in the
environment when I run ant or any java application.  I believe on setting
the environment on a per process basis.  That being said if the exact same
ant script runs on XP and not on 2000 then my best guess would be that the
CLASSPATH env var is being set differently on each machine.  Meaning that
the XP machine might be setting the CLASSPATH as a System (global) variable
and the 2000 machine might be setting as a user variable different from the
user logged in or more likely there is a System var set is correct but there
might be a CLASSPATH var set for the user logged in that is masking the one
you think is being used.

If this is not the case I recommend setting the classpath spcifically within
the java task and removing from the environment altogether.  If this does
not fix your problem then I recommend running ant -diagnostics on both
machines as well as running the script in debug mode for both machines to
see what may be the problem.  I faintly recall another issue with
environment variables XP vs Win2000 but I don't think it applies here.


Now I've gained some understanding
Of the only world that we see.
Things that I once dreamed of
Have become reality.

These walls that still surround me
Still contain the same old me,
Just one more who's searching for
A world that ought to be.
  ----- Original Message ----- 
  From: Rhino
  To: ant-user
  Sent: Wednesday, July 14, 2004 9:12 AM
  Subject: Basic Questions about Classpath

  I am trying to help my friend Ron with a problem we were having on his
Windows 2000 machine yesterday. He has already posted about it but I just
want to review the basic concept in case I'm missing something conceptual.
These questions refer to Ant 1.6.1.
    1.. Am I right in assuming that a <java> task that does not contain a
classpath attribute will use the value of the system property
java.class.path, which is derived from the CLASSPATH environment variable
currently in effect? Will this be true for both <java> tasks that are
executing .class files and <java> tasks that are executing jar files?
    2.. Am I right that a <java> task which *does* contain a classpath
attribute will use only the classpath specified in the attribute and ignore
any classpath set in the CLASSPATH environment variable?
  I am trying to understand why a <java> task that I wrote works fine on XP
without any classpath attribute yet doesn't work on Windows 2000, regardless
of whether I use a classpath attribute or not. On both platforms, the
CLASSPATH environment variable includes the jar file the program needs to
see in order to execute correctly.

  rhino1 AT sympatico DOT ca
  "There are two ways of constructing a software design. One way is to make
it so simple that there are obviously no deficiencies. And the other way is
to make it so complicated that there are no obvious deficiencies." - C.A.R.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message