Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:29:15+00:00 2026-06-07T20:29:15+00:00

I’m sorry this is a newbie question, but i’m having some problems with Ant,

  • 0

I’m sorry this is a newbie question, but i’m having some problems with Ant, and i’m not really sure about how to solve them.

I don’t know how to add a folder containing png and jpg images. Those images will be later be displayed, and will be called using the command:

new URL("file:///" + System.getProperty("user.dir") + "\\img\\IMAGENAMEHERE.png")

The files are in the folder /img in the folder next to /src.

So, i have my ant build file, and my classpath is:

<path id="classpath">
    <fileset dir="libs">
        <include name="**/*.jar" />
    </fileset>
    <pathelement location="${build}" />
    <pathelement location="${instrumented.dir}" />
    <pathelement location="${build}/tests" />
    <pathelement location="${libs}" />
    <pathelement location="${img}" />
</path>

Since that didn’t work, i tried copying the images into the build folder (in the ant build file, i create a build folder and a bin folder)

<target name="setup">
    <delete dir="${build}" />
    <mkdir dir="${build}"/>
    <mkdir dir="${build}/app"/>
    <mkdir dir="${build}/tests"/>

    <copy todir="${build}/img"> 
        <fileset dir="${img}" >
            <include name="**/*.png" />
            <include name="**/*.jpg" />
        </fileset> 
    </copy>
</target>

But that didn’t work either, and i don’t know what to do. The problem is, whenafter i compile with Ant, i got this error when i run it in the console calling java StartProgram :

Unable to obtain resource from C:\folder\img\salidaCerrada.png: java.util.zip.ZipException: error in opening z
ip file
    [junit] Unable to obtain resource from C:\folder\img\salidaCerrada.png:
    [junit] java.util.zip.ZipException: error in opening zip file
    [junit]     at java.util.zip.ZipFile.open(Native Method)
    [junit]     at java.util.zip.ZipFile.<init>(ZipFile.java:127)
    [junit]     at java.util.jar.JarFile.<init>(JarFile.java:135)
    [junit]     at java.util.jar.JarFile.<init>(JarFile.java:99)
    [junit]     at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLo
ader.java:1006)

Any idea? Thank you beforehand.

Edit: I forgot to mention that i’m not creating a .jar file, but just testing my application and compiling it (creating .class files). The images aren’t in a .jar file either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:29:17+00:00Added an answer on June 7, 2026 at 8:29 pm

    My first thought is that your ${img} element isn’t pointing to anywhere. If you used a tool to create your build.xml file then it probably created the ${libs} and other properties. First you should replace the ${img} with just ‘img’ (no quotes).

    My second thought is that you are looking for the images in the “working” directory, but that may not be set to what you think it should be, especially if your running inside some other tool. I suggest you print out the value of System.getProperty(“user.dir”) to see what it actually is. Depending on what you need to do, you will probably get better results if you load the images from the class path (you should be able to find some good tutorials on how to load a Resource Stream from the class path).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.