I have an ant build script for a project which depends on an external jar. The location of the external jar is available in Eclipse as a variable (say, JJ2000_LIB, added through “Add variable” in project properties > Java Build Path > Libraries).

How do I access such Eclipse library variables from ant?
Ideally I would like to be able to also run the same ant script from the command line and be able to set this variable.
I’ve tried env.JJ2000_LIB which works from the command line (if I set a environment variable), but not from within Eclipse. My build.xml contains:
<property environment="env" />
<property name="jj2000_lib" value="${env.JJ2000_LIB}" />
<target>
<javac srcdir="${src}" classpath="${jj2000_lib}" destdir="${build}" />
</target>
Basically if you want to add a jar to your project you need to: click with right of mouse “add to build path” (almost the same that you did).
then in the build you have to put something like this:
Obviously you need to set the right path. It works for me.
edit: the in the manifest you should put a line like this:
Class-path: youJar.jar
EDIT:
classhpath variables (the one you define) seems to be incompatible with ant and to be used in ant (I found some bug posts in eclipse developer forum, but no one fixed). So it seems there’s no way to use a classpath variable. I tried few hours to find a solution for you, now the best thing I can do for you is link this site:
http://www.ant4eclipse.org
maybe that’s the solution.