You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by RogerL <li...@hotmail.com> on 2007/09/23 07:41:25 UTC

Ant didn't include image resource into classpath?

 hi guys,

i have this package

view/MyFrame.java
view/res/home.gif

In MyFrame.java, i try to load the image using
ImageIcon ic = new ImageIcon("view/res/home.gif");

using eclipse ide, everything works fine, but when i use ant script to do
the job, the image didn't appear.

my build xml
<project name="Test" default="compile">

    <property name="sourcedir" value="${basedir}/src"/>
    <property name="targetdir" value="${basedir}/bin"/>
    <property name="librarydir" value="${basedir}/lib"/>

    <path id="libraries">
        <fileset dir="${librarydir}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="clean">
        <delete dir="${targetdir}"/>
        <mkdir dir="${targetdir}"/>
    </target>

    <target name="compile" depends="clean, copy-resources">
      <javac srcdir="${sourcedir}"
             destdir="${targetdir}"
             classpathref="libraries"/>
    </target>
	
	<target name="copy-resources">
        <copy todir="${targetdir}">
            <fileset dir="${sourcedir}">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
	
	<target name="run" depends="compile">
    <java fork="true" classname="view.MyFrame" classpathref="libraries">	
    <classpath>
      <pathelement path="${targetdir}"/>
	</classpath>
    </java>
</target>

</project>

i did copy the resource to my targetdir during compilation. Anyone has any
idea what is wrong? thank you!
-- 
View this message in context: http://www.nabble.com/Ant-didn%27t-include-image-resource-into-classpath--tf4503226.html#a12843041
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