ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: cannot find symbol
Date Mon, 15 Jun 2009 18:00:20 GMT
It looks like they're defining a classpath called "classpath" (easy enough
to remember). Have you looked at the Ant documentation at <
http://ant.apache.org/manual/index.html>?

The "path" called "classpath" is defined by all of the jarfiles located
under the directory called ${lib_dir}. You will have to look at your
build.xml file to see where ${lib_dir} is defined. You should see something
like this:

    <property name="lib_dir" value="some_directory"/>

It is similar to a Windows batch script setting an environment variable:

    set lib_dir=some_directory

Make sure all of the jarfiles you need are located inside this ${lib_dir}.

There is one more property called ${java.class.path} that is also added to
this classpath. Is this defined anywhere inside your buld.xml file?

The question is whether you're suppose to compile with java.class.path or
classpath.   There isn't much explanation which one you should use.

If you're suppose to compile with classpath, you need to do this:

<javac
srcdir="${src.dir}"
destdir="${dest.dir}"
*classpathref="classpath"*/>

Otherwise, if you're suppose to use java.class.path, you would do this:

<javac
 srcdir="${src.dir}"
destdir="${dest.dir}"
*classpath="${java.class.path}"*/>


On Mon, Jun 15, 2009 at 1:03 PM, Hungry Snail <centurion3@hotmail.com>wrote:

>
> Hi David,
>
> Many thanks for the reply.
>
> I am using a script that someone sent me, this is the first time I have
> ever
> attempted to compile anything :).
>
> <path id="classpath">
>        <fileset dir="${lib_dir}">
>                <include name="*.jar" />
>        </fileset>
>        <pathelement path="${java.class.path}" />
>  </path>
>
> This is what is in the build.xml
>
> by looking at that I am guessing that the class path isnt actually defined?
>
> Regards
>
>
> David Weintraub wrote:
> >
> > This isn't an Ant error as much as a "javac" command error. What you're
> > being told is that a particular program is trying to resolve a symbol,
> but
> > can't find the reference to that symbol. For example, these particular
> > classes are defined in a jarfile called something like
> > org.eclipse.swt.<shell>.<OS>_<version>.jar which lives in your
Eclipse
> > installation. On my system it is called
> > org.eclipse.swt.gtk.linux.x86_64_3.4.1.v3449c.jar. On a Windows system,
> it
> > might be org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar.
> >
> > When you run the <javac> task, you must make sure this jarfile is in the
> > classpath.
> >
> > There are multiple ways of setting the classpath when you compile using
> > the
> > <javac> command. One is to set the "classpath" parameter itself. Another
> > is
> > to use a "reference" to set the classpath, and then use the classpathref
> > parameter. This is nicer since it gives you a bit more flexibility. Here
> > I'm
> > defining a classpath called "class.path":
> >
> > <path id="class.path">
> >    <fileset dir="${basedir}/lib">
> >        <include name="**/*.jar"/>
> >    </fileset>
> >    <pathelement file="${some.other.jar.file.I.need"/>
> > </path>
> >
> > Now, you can add and subtract jarfiles your build depends upon by simply
> > adding them to the ${basedir}/lib directory. You no longer have to modify
> > your build.xml file every time someone adds a new jarfile dependency. You
> > can compile like this:
> >
> > <javac
> >   srcdir="${src.dir}"
> >   dest="${target.dir}/classes"
> >   *classpathref="class.path"*/>
> >
> > Now, you're referencing the path "class.path" as your classpath for your
> > "javac" command.
> >
> > Another way is to use a sub-task:
> >
> > <javac
> >   srcdir="${src.dir}"
> >   destdir="${target.dir}/classes">
> > * <classpath>**
> >     <fileset dir="${basedir}/lib">
> >          <include name="**/*.jar"/>
> >     </fileset>
> >      <path refid="class.path2"/>
> >      <pathelement file="${some.other.jar.file.I.need"/>
> >   </classpath>*
> > </javac>
> >
> > This allows you to build more complex classpaths that might be possible
> > with
> > a single reference. Notice that I am using fileset, pathelement, and even
> > a
> > reference to a previously defined path called "class.path2".
> >
> > How do you compile  your code now? Are you using a script? If so, what is
> > the classpath used by the javac command in your script? That'll help you
> > understand what should be in your classpath when you run <javac>.
> >
> > On Mon, Jun 15, 2009 at 7:44 AM, Hungry Snail <centurion3@hotmail.com>
> > wrote:
> >>
> >> Hi People.
> >>
> >> I am trying to compile some files with ant but am getting the following
> >> errors.
> >>
> >>  [javac] D:\Stats\src\org\selectbf\gui\ConfigurationDialog.java:32:
> > package
> >> org.eclipse.swt.widgets does not exist
> >>  [javac] import org.eclipse.swt.widgets.Text;
> >>  [javac]                                ^
> >>  [javac] D:\Stats\src\org\selectbf\gui\ConfigurationDialog.java:50:
> > package
> >> org.eclipse.swt.widgets does not exist
> >>  [javac] public class ConfigurationDialog extends
> >> org.eclipse.swt.widgets.Dialog
> >>  [javac]
> >> ^
> >>  [javac] D:\Stats\src\org\selectbf\gui\ConfigurationDialog.java:53:
> >> cannot
> >> find symbol
> >>  [javac] symbol  : class Shell
> >>  [javac] location: class org.selectbf.gui.ConfigurationDialog
> >>  [javac]     private Shell dialogShell;
> >>  [javac]             ^
> >>  [javac] D:\Stats\src\org\selectbf\gui\ConfigurationDialog.java:54:
> >> cannot
> >> find symbol
> >>  [javac] symbol  : class TabItem
> >>  [javac] location: class org.selectbf.gui.ConfigurationDialog
> >>  [javac]     private TabItem generalTabItem;
> >>
> >> In total there are 100 of these errors :-o.
> >>
> >> As I have never used ant before, is there anything I can do to fix this?
> >>
> >> Thanks in advance.
> >> --
> >> View this message in context:
> > http://www.nabble.com/cannot-find-symbol-tp24033173p24033173.html
> >> Sent from the Ant - Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >> For additional commands, e-mail: user-help@ant.apache.org
> >>
> >
> >
> >
> > --
> > David Weintraub
> > qazwart@gmail.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/cannot-find-symbol-tp24033173p24038655.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
David Weintraub
qazwart@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message