• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layout

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Am trying to create a jar file in eclipse using some .java file. It is generating jar perfectly, also my application runs perfectly in eclipse. But when i run the jar using the following command
java -jar report.jar
It is throwing an error as, Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layout.
Can any one help in solving my problem.
 
Sheriff
Posts: 22504
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you added the Log4J JAR file to the Class-Path attribute inside your manifest?
 
swathi ramesh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, i have created jar in eclipse, so it is creating the manifest file. Also, it creates the .classpath file and it has set the log4j path in it.
i tried to extract the jar and added the classpath attribute in manifest file, and executed the jar. Then it is throwing a error as file has been corrupted.
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

swathi ramesh wrote:Actually, i have created jar in eclipse, so it is creating the manifest file. Also, it creates the .classpath file and it has set the log4j path in it.
i tried to extract the jar and added the classpath attribute in manifest file, and executed the jar. Then it is throwing a error as file has been corrupted.


Did you create the jar properly? By using jar command and providing the new manifest file?
 
swathi ramesh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried, but no use. Can you tell me the procedure exactly, may be am missing some thing.
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

swathi ramesh wrote:i tried, but no use. Can you tell me the procedure exactly, may be am missing some thing.


You can get it from jar command's help. Just execute jar command without any options. It'll tell you about supported options and their respective meanings. Also, make sure that your log4j jar actually exists at one of the locations you've mentioned in classpath (which is part of manifest file).
 
swathi ramesh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried an example with all java files not in a package structure., it is working good. But when i tried with package structure, it is not working.
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

swathi ramesh wrote:I tried an example with all java files not in a package structure., it is working good. But when i tried with package structure, it is not working.


You mean to say that it worked when you put all files in single directory? It means you are not having package structure, but only one package for all files. If you want to have a package structure, then you'll have to define different packages and recompile all files (which is quite easy if done via eclipse).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic