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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:58:40+00:00 2026-06-09T16:58:40+00:00

I have created a simple project in java using eclipse ide to test the

  • 0

I have created a simple project in java using eclipse ide to test the log4j functionality.
I need to run the application from the command prompt using the jar tool in java.
The logtest.java file is simple java file which defines a logger as below.
It is referencing a Logger which is in another Jar file. below is directory structure.

package com;

import org.apache.log4j.Logger;

public class logtest {

    private static Logger logger = Logger.getLogger(logtest.class);

    public static void main(String[] args) {
        System.out.println("---------------HIIIIII-----------");
    }

Below is the directory structure that i have created in the project in eclipse.

src/com/logtest.java

lib/log4j-1.2.17.jar

the manifest files entries are as below and i have manually created the maifest file.

Manifest-Version: 1.0
Main-Class: com.logtest
Class-Path: lib/log4j-1.2.17.jar

The contents of the Jar file are as below which i unzipped using the jar utility.

META-INF/MANIFEST.MF
.project
com/logtest.class
manifest.mf
lib/log4j-1.2.17.jar
.classpath

I have exported the jar file and when i try to run using the commond java -jar JarTest2.jar i am getting the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at com.logtest.<clinit>(logtest.java:6)

Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader$1.run(Unknown Source)
    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)
    ... 1 more

I know its a class not found exception but strange thing is that the same jar when i create using jdk1.5 and run command tool the jar runs successfully and the java class executes without any error.

I have no idea why this is going as everything is the same.

mine is a 64 bit windows 7 machine and the other machine where it is running is a 32 bit XP machine.

Of course the version of eclipse ide is different on both machines.

Can you please let me know is there something wrong about what i am doing or am i missing something else.

Thanks
Vikeng21

  • 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-09T16:58:42+00:00Added an answer on June 9, 2026 at 4:58 pm

    I’m pretty sure that Java doesn’t support embedded Jars. I’d recommend moving the lib/log4j-1.2.17.jar file out to the file system (so that it creates a sub folder ./lib within the same drctory as your executable Jar & see if that makes a difference.

    If you really want to use embedded Jars, you could take a read of One-Jar

    You should have a directory structure of

    .\JarTest2.jar
    .\lib\log4j-1.2.17.jar
    

    On your file system. The log4j Jar shouldn’t be imbedded (contained within) the JarTest2.jar file

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

Sidebar

Related Questions

I have created a simple java web (Vaadin) application project using JPA and it
I am using Eclipse with WindowsBuilder. I have created a small simple project to
We have created a simple wix project for a basic windows application. Everything builds
I have created an applet program using Eclipse IDE. Now im creating .html file
I am trying to run a simple Java project. I had created a project
I have created a jar file in Eclipse of my Java project in JRE
I have a project in Eclipse which mixes native and Java code using CDT
I have created some simple app in Java, and 'deployed' it using Java Web
I have created a very simple GUI project in Qt as follows: main: #include
i have created a simple public ref class in the vc++ project, which is

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.