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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:57:15+00:00 2026-05-15T15:57:15+00:00

I compile and run my program in Eclipse and everything works fine, but when

  • 0

I compile and run my program in Eclipse and everything works fine, but when I package it with Ant and run it, I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/supercsv/io/ICsvB
eanReader
Caused by: java.lang.ClassNotFoundException: org.supercsv.io.ICsvBeanReader
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: jab.jm.main.Test. Program will exit.

Note that this is a runtime error and not a compiler error with Ant.

I’ve built this project in the past with 0 issues and now it suddenly acts up on me when I add a second package to my lib folder?

Here’s the build file for reference:

<?xml version="1.0" ?>

<project name="ServerJar" default="dist" basedir=".">
 <description>
  Builds client files into .jar
 </description>
 <!-- [build variables] -->
 <property name="src" location="src" />
 <property name="build" location="build" />
 <property name="dist" location="dist" />
 <property name="lib" location="lib" />
 <!-- [path to packages] -->
 <path id="master-classpath">
     <fileset dir="${lib}">
         <include name="*.jar"/>
     </fileset>
 </path>


 <target name="init">
  <!-- makes time stamp to be used in jar name -->
  <tstamp />
  <!-- creates build directory structure -->
  <mkdir dir="${build}" />
 </target>

 <target name="compile" depends="init" description="Compiles the source">
  <!-- compiles the java code from ${src} into ${build} -->
  <!-- <javac srcdir="${src}" destdir="${build}" /> -->
  <javac destdir= "${build}">
      <src path="${src}"/>
      <classpath refid="master-classpath"/>
  </javac>
 </target>

 <target name="dist" depends="compile" description="Generates distributable">
  <!-- creates the distribution directory -->
  <mkdir dir="${dist}/lib" />

  <!-- puts everything in ${build} into the jar file -->
  <jar jarfile="${dist}/lib/CC-${DSTAMP}.jar" basedir="${build}">
   <manifest>
    <attribute name="Main-Class" value="jab.jm.main.Test" />
   </manifest>
  </jar>

  <!-- makes a jar file for quick test execution -->
  <jar jarfile="${dist}/lib/CC.jar" basedir="${build}">
   <manifest>
    <attribute name="Main-Class" value="jab.jm.main.Test" />
   </manifest>
  </jar>
 </target>

 <target name="clean" description="Cleans up the extra build files">
  <!-- deletes the ${build} and ${dist} directories -->
  <delete dir="${build}" />
  <delete dir="${dist}" />
 </target>
</project>

Thanks in advance for the help!

EDIT:

Here’s what the construction for my main class looks like (this is not the actual file, but this is what I based mine on). The construction is very odd for a java program and might be giving Ant some issues. Any recommendations on how to reconstruct this? I got a bunch of errors when trying to separate this into multiple parts. I’ve just never seen a construction like this before (yes, I understand HOW it works (and it does when compiled), but Ant might not like it).

import java.io.FileReader;
import java.io.IOException;

import org.supercsv.cellprocessor.Optional;
import org.supercsv.cellprocessor.ParseDate;
import org.supercsv.cellprocessor.ParseInt;
import org.supercsv.cellprocessor.constraint.StrMinMax;
import org.supercsv.cellprocessor.constraint.Unique;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.io.CsvBeanReader;
import org.supercsv.io.ICsvBeanReader;
import org.supercsv.prefs.CsvPreference;

class ReadingObjects {
    static final CellProcessor[] userProcessors = new CellProcessor[] {
        new Unique(new StrMinMax(5, 20)),
        new StrMinMax(8, 35),
        new ParseDate("dd/MM/yyyy"),
        new Optional(new ParseInt()),
        null
    };

    public static void main(String[] args) throws Exception {
        ICsvBeanReader inFile = new CsvBeanReader(new FileReader("foo.csv"), CsvPreference.EXCEL_PREFERENCE);
        try {
          final String[] header = inFile.getCSVHeader(true);
          UserBean user;
          while( (user = inFile.read(UserBean.class, header, userProcessors)) != null) {
            System.out.println(user.getZip());
          }
        } finally {
          inFile.close();
        }
   }
}

public class UserBean {
    String username, password, town;
    Date date;
    int zip;

    public Date getDate() {
        return date;
    }
    public String getPassword() {
        return password;
    }
    public String getTown() {
        return town;
    }
    public String getUsername() {
        return username;
    }
    public int getZip() {
        return zip;
    }
    public void setDate(final Date date) {
        this.date = date;
    }
    public void setPassword(final String password) {
        this.password = password;
    }

    public void setTown(final String town) {
        this.town = town;
    }
    public void setUsername(final String username) {
        this.username = username;
    }
    public void setZip(final int zip) {
        this.zip = zip;
    }
}

Notice how the class’s name is actually UserBean and it contains a non-public class named ReadingObjects within it that holds the main method.

  • 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-15T15:57:15+00:00Added an answer on May 15, 2026 at 3:57 pm

    Looks like your runtime classpath is missing the jar containing the class org.supercsv.io.ICsvBeanReader.

    The gotcha is that you cannot set the classpath from the command-line when calling an executable jar. You have to set it within the manifest as follows:

    <target name="dist" depends="compile" description="Generates distributable">
        <!-- creates the distribution directory -->
        <mkdir dir="${dist}/lib" />
    
        <!-- Remove manifest. This jar will end up on the classpath of CC.jar -->
        <jar jarfile="${dist}/lib/CC-${DSTAMP}.jar" basedir="${build}"/>
    
        <!-- Fancy task that takes the pain out creating properly formatted manifest value -->
        <manifestclasspath property="mf.classpath" jarfile="${dist}/lib/CC.jar">
            <classpath>
                <fileset dir="${dist}/lib" includes="*.jar"/>
            </classpath><!--end tag-->
        </manifestclasspath>
    
        <!-- This is the executable jar -->
        <jar jarfile="${dist}/lib/CC.jar" basedir="${build}">
            <manifest>
                <attribute name="Main-Class" value="jab.jm.main.Test"/>
                <attribute name="Class-Path" value="${mf.classpath}"/> 
            </manifest>
        </jar>
    
    </target>
    

    This approach will allow you to run the jar as follows:

    java -jar CC.jar
    

    Without the extra manifest entry you have to run the jar as follows:

    java -cp CC.jar:CC-DSTAMPVALUE.jar jab.jm.main.Test
    

    Note

    Only the CC.jar is executable and needs the special manifest. Using this pattern means future additional jars, placed into the lib directory, will be automatically included in the run-time classpath. (Useful for open source dependencies like log4j)

    Obviously, when running the CC.jar you’ll get a similar error if the jar files are not present 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 440k
  • Answers 440k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In your Wordpress administration console go to "Appearance->Widgets" Locate the… May 15, 2026 at 5:23 pm
  • Editorial Team
    Editorial Team added an answer Canvas doesnt support javascript, but SVG does. You could use… May 15, 2026 at 5:23 pm
  • Editorial Team
    Editorial Team added an answer The requesting domain must match the requested domain down to… May 15, 2026 at 5:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.