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 3991848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:39:54+00:00 2026-05-20T06:39:54+00:00

<target name=run depends=jar> <java fork=true classname=${main-class}> <classpath> <path refid=classpath/> <path location=${jar.dir}/${ant.project.name}.jar/> </classpath> </java> </target>

  • 0
 <target name="run" depends="jar">
        <java fork="true" classname="${main-class}">
          <classpath>
                <path refid="classpath"/>
                <path location="${jar.dir}/${ant.project.name}.jar"/>
        </classpath>
        </java>
    </target>

Why I cannot use something like

   <java jar="build/jar/HelloWorld.jar" fork="true" >
          <classpath>
             <path refid="classpath"/>  
            <path location="${jar.dir}/${ant.project.name}.jar"/>   
  </classpath> 
   </java> 

I received the error like

 [java] java.lang.NoClassDefFoundError: org/apache/log4j/Logger
 [java]     at oata.HelloWorld.(Unknown Source)
 [java] Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
  • 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-05-20T06:39:55+00:00Added an answer on May 20, 2026 at 6:39 am

    According to the java task documentation, your second example should just work as expected (except that the classpath will be ignored).

    Edit: The information you added to your question implies a few things:

    1. the .jar file is found
    2. it has the correct Main-Class entry in its manifest
    3. your application requires log4j
    4. it does not have a correct Class-Path entry pointing to a log4j.jar file

    Basically the java ant task has the same requirements as using java -jar on the command line: if your .jar file doesn’t correctly run using java -jar myApp.jar on the command line, then the java Ant task won’t work like that either.

    Edit 2: Whenever you invoke a .jar file directly in Java, then no further classpath can be specified in any way. That’s true when you use java -jar myApp.jar and it’s also true when you use the java Ant task with the jar attribute. That means that the .jar file itself must have a correct Class-Path entry.

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

Sidebar

Related Questions

<target name=results> <echo message=Calculating QI /> <java jar=jmt.jar fork=true failonerror=true maxmemory=1024m classpath=jmt/jmt> <arg value=-name:KIS/>
When I run the following script in HSQLDB 2.2.5 using the command java -jar
I have the following tasks in ant: <target name=init-junit depends=init> <mkdir dir=${junit.reports.individual} /> <property
How can I rewrite this code to coffeescript: $('.delete_action').click(function(event) { $.get('/delete_action?name=' + event.target.name +
Suppose I have this annotation @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Name { String value(); }
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'PNLResultDAOImpl' defined in file [C:\EclipseWS1\SpringJDBCExample\target\classes\com\synechron\tom\pnl\dao\impl\PNLResultDAOImpl.class]: Instantiation of bean
The code: object Link { //TYPE-1 (purely functional) def apply(name: String, target: Page, f:
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left
Target failed to run: Remote exception encountered: Faild to get task for pid 3103
i have made an android application for Project Build Target as Target name:: Android

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.