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

  • SEARCH
  • Home
  • 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 7761157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:04:10+00:00 2026-06-01T14:04:10+00:00

I’ve found examples on how to either set the classpath so that a Java

  • 0

I’ve found examples on how to either set the classpath so that a Java program can be executed or to include external jars, but not both. My attempts to combine multiple examples in one file have failed.

My source .java files are in the src directory, the file I want to execute is src/TEDI.java, the class files get put correctly into the build directory, and all my jars are in the directory jung2-2_0_1. I can get my program to compile, but not execute, using the following ant file:

<?xml version="1.0"?>
<project name="TEDI" basedir="." default="execute">
    <property name="src" value="src"/>
    <property name="output" value="build"/>
    <property name="lib" value="jung2-2_0_1"/>

    <target name="execute" depends="compile">
        <echo>
            Executing TEDI.
        </echo>
        <java classname="${output}/TEDI.class">
            <classpath refid="java"/>
        </java>
    </target>

    <target name="compile" depends="create">
        <echo>
            Compiling source files.
        </echo>
        <javac destdir="${output}">            
            <src path="${src}"/>            
            <classpath refid="java"/>
        </javac>
    </target>

    <target name="clean">
        <echo>
            Deleting old class files.
        </echo>
        <delete dir="${output}"/>
    </target>

    <target name="create" depends="clean">
        <echo>
            Creating output directory.
        </echo>
        <mkdir dir="${output}"/>
    </target>

    <path id="java">
        <pathelement location="${output}"/>
        <fileset dir="${lib}">
            <include name="*.jar"/>
        </fileset>
    </path>
</project>

When I run ant, it does the clean, create, and compile targets just fine, and then when it gets to execute it says: Could not find build/TEDI.class. Make sure you have it in your classpath

Anyway I’m hoping someone can tell me what I’m doing wrong in the path section. I added the pathelement bit after reading one example on how to create an ant target to execute a file, but it didn’t help at all. There are a ton of examples and a lot of them do things differently to achieve the same thing (while none do exactly what I’m trying to do), so I can’t figure out which way is correct for what I’m trying to do. Any help or ideas would be greatly appreciated.

Edit: Changed <pathelement location="${build}"/> to <pathelement location="${output}"/> as per Sandro’s answer, but it doesn’t change the error message at all.

  • 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-01T14:04:12+00:00Added an answer on June 1, 2026 at 2:04 pm

    The java task expects a Java class name, not the path of a class file.
    So you should use

        <java classname="TEDI">
    

    instead of

        <java classname="${output}/TEDI.class">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am doing a simple coin flipping experiment for class that involves flipping a

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.