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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:25:20+00:00 2026-06-12T03:25:20+00:00

I want to create a jar file from a maven java project and add

  • 0

I want to create a jar file from a maven java project and add this as an external jar file in another project. However I keep getting a NoClassDefFoundError error.

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at com.tutelatechnologies.dashboard.DataUsageLogs.Logging.getlogger(Logging.java:10)
    at com.tutelatechnologies.dashboard.DataUsageLogs.Logging.d(Logging.java:26)
    at com.tutelatechnologies.dashboard.DataUsageLogsRunner.DUL_TESTER.main(DUL_TESTER.java:11)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 3 more

The jar file is very simple. It merely contains wrappers for logging with Log4J and SLF4J. I’ve included it blow:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Logging {

    public void e(String msg, Class inputClass)
    {
        Logger logs = LoggerFactory.getLogger(inputClass);
        logs.error(msg);
    }
    public void w(String msg, Class inputClass)
    {
        Logger logs = LoggerFactory.getLogger(inputClass);
        logs.warn(msg);
    }
    public void d(String msg, Class inputClass)
    {
        Logger logs = LoggerFactory.getLogger(inputClass);
        logs.debug(msg);
    }
    public void t(String msg, Class inputClass)
    {
        Logger logs = LoggerFactory.getLogger(inputClass);
        logs.trace(msg);
    }    
}

Now I right-click this project, select Export -> Java -> Jar File then click Finish. Leaving all the folders selected.

I then go to my new project and add the jar file by right-clicking my project, select Build Path-> Configure Build Path. Then in the Libraries tab I click the “Add external Jars” button and link it to my jar file. I attach my source code and a javadoc so I can verify it’s linked correctly. It looks to be ok, but when I run it I get NoClassDefFoundError. This is because eclipse doesn’t seam to be adding in the dependencies to the jar file.

I can get this to work if I add the project to the Java Build path. But I want this to be a self contained jar file. It falls apart when It hits LoggerFactory.getLogger(inputClass); which is looking for the slf4j dependency.

The following line is the only line used in testing this.

Logging.d("test", thisClass.class);

Is it possible to get all dependencies packed into a single jar file and have it link correctly?

FYI, I’ve tried making this a Runnable Jar, which seams to work but then the jar file doesn’t know how to link to the log4j.properties file. This file is located in src/main/resources.

Any help is appreciated.

Cheers,

  • 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-12T03:25:22+00:00Added an answer on June 12, 2026 at 3:25 am

    I’m not sure exactly what the issue was, but I was able to get it working. I exported the file, but with only the relevant source and property file selected. Then I added it to the top of the list of my other projects Order and Export tab.

    Ultimately I added the jar as a maven dependency, and then added all the necessary dependencies for the jar to the new project as well, and that worked.

    Cheers.

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

Sidebar

Related Questions

I want to create a jar file from one android project for another android
I want to create registry key through java program to add the jar file
i want to create a jar file of my java web application. This web
I created a Jar file from my java code : public void create() throws
I want to create my Android virtual device from another java application. I don't
I'm new to Scala and don't know Java. I want to create a jar
I would like to determine the jar file name from my java code. I
I have a .jar file I'm putting together. I want to create a really
I've downloaded scalaz snapshot from repository (version 6.0.4). I want to create standalone jar
i want create multiple search where statement $where_search is a multiple condition from post

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.