Cannot find class in jar

Hi,
I have a single application and I wanted to employ logging in that application. Here is my folder structure
root-
|-com
| |-xyz
| |-Application
|-lib
| |-log4j-1.2.11.jar
When I run this with the command java -cp lib/log4j-1.2.11.jar;.;  com.xyz.Application, it works fine.
But, when I jar the application with its manifest file looking as
Manifest-Version: 1.0
Class-Path: lib/log4j-1.2.11.jar
Main-Class: com.xyz.Applicationand the command as java -jar application.jar it gives me a Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at com.xyz.Application.<clinit>(Application.java:20)Could any one please help me out over here?

Make this an absolute path, not relative.
Class-Path: lib/log4j-1.2.11.jarIt is a classpath, and needs to look like one.

Similar Messages

  • Preverification error: Cannot find class com/sun/perseus/model/Viewport

    Hi all,
    I have a (previously) working Midlet to which I have added one line as follows:
    SVGImage image = (SVGImage)SVGImage.createEmptyImage(null);
    - and imported the necessary from javax.microedition.m2g. (I am using the library that comes with the WTK, jsr226.jar).
    This builds, jars, obfuscates fine. But when I try to preverify (using Antenna's wtkpreverify) on the jar, it gives up in disgust very swiftly as follows:
    [wtkpreverify] Error preverifying class javax.microedition.m2g.ScalableGraphics
    [wtkpreverify] VERIFIER ERROR javax/microedition/m2g/ScalableGraphics.render(IILjavax/microedition/m2g/ScalableImage;)V:
    [wtkpreverify] Cannot find class com/sun/perseus/model/Viewport
    I'm using the WTK2.5.1ea and antenna 0.9.14, CLDC1.1, MIDP2.0...
    Many thanks for any ideas.

    Problem resolved simply by replacing jsr226.jar (as distributed with WTK2.5.1ea) with m2g.jar (as distributed with J2MEPolish).

  • Cannot find class: Exception??

    Hi
    The compiler claims it cannot find class FileNotFoundException or any other exception in my Main. Any packages I import has no problem. My structure:
    java \ myMain \ Main.java
    java \ com \ myName \ packages //no, the space is just there as visual help:)
    Use javac -classpath java\ @compile.file
    ...where compile.file is a txt file giving the paths and filenames to all files I include.
    This is first time I use the -classpath parameter, but I believed java.lang always was included. What Am I doing wrong.
    regards
    JT

    You should review the tool documentation for the javac command and its use of classpath.
    Your problem appears to be due to the way you defined classpath, "-classpath java\". While you don't provide enough information to conclusively say what it should be, I'm guessing it should also include java\myMain\ - assuming that you're issuing the javac command from the parent of the \java\ directory, as your command example indicates.
    Here is a clip about its use of the classpath.
    "When compiling a source file, the compiler often needs information about a type whose definition did not appear in the source files given on the command line. The compiler needs type information for every class or interface used, extended, or implemented in the source file. This includes classes and interfaces not explicitly mentioned in the source file but which provide information through inheritance.
    For example, when you subclass java.applet.Applet, you are also using Applet's ancestor classes: java.awt.Panel, java.awt.Container, java.awt.Component, and java.lang.Object.
    When the compiler needs type information, it looks for a source file or class file which defines the type. The compiler searches for class files first in the bootstrap and extension classes, then in the user class path (which by default is the current directory). The user class path is defined by setting the CLASSPATH environment variable or by using the -classpath command line option. (For details, see Setting the Class Path).
    If you set the -sourcepath option, the compiler searches the indicated path for source files; otherwise the compiler searches the user class path for both class files and source files."

  • Cannot find class JPanel

    Hi,
    Im trying to use swing for almost the first time.
    I changed my system to Linux and installed J2sdk 1.4.
    When I write a class
    e.g.
    import javax.swing.*;
    import java.awt.*;
    etc...
    class Test extends JPanel {
    I receive an error message "Cannot find class "JPanel""
    Can anyone help ? Maybe I didnt install the right thing ?
    Thanks
    Ulrike

    you sure reinstall and overwrite your current sdk. Do you have the runtime environment installed too -- should come with the sdk

  • Cannot find class java/lang/Thread

    I'm getting this error trying to compile a program that I'm writing in java. Its a very simple program just to get me back to basics. Any ideas as to how I can fix this problem??

    Extracted from Sun's website,
    * Error Message: "Exception in thread NULL" or
    "Unable to initialize threads: cannot find class java/lang/Thread"
    If you are getting one of these fatal error messages when running java,
    javac, or appetviewer, you should check your CLASSPATH environment variable.
    It may list "c:\java" or the "classes" directory from an older release. You can either unset the CLASSPATH variable, or set it to
    include only the latest version of the Java platform class library. For example:
    C:\> set CLASSPATH=.;C:\jdk1.1.8\lib\classes.zip
    This will make sure that you are using the correct classes for this release.
    -- Sudha

  • Cannot find class "Hello"

    Hi,
    I'm developing a application for a windows ce v.2.11, and I've installed in my PDA (MIPS) Personal Java. The samples of Personal Java run perfectly. I've create a simple new class (Hello.class) with Sun One Studio, then I copy this file (Hello.class) in my pda, and when I run the application I saw this messages: "Cannot find class Hello".
    Anybody can explain me step by step the correct way to create a new class or a new jre to run in my PDA?
    Another question: Where are installed the classes as AWT?
    Thanks

    Please see my reply to your latest post.

  • Error:Cannot find class

    Hi
    I compile my application correctly, but when I copy this application in my PDA, and run this application (Hello.class) with Personal Java I saw a this message: Cannot find class Hello.class.
    I don't compile javacheck before copy in my PDA the application.
    Please help me

    Hi,
    are you sure that your classpath is set correct?
    For checking this you'll need a registry editor and check the command that is entered for the .class file extensions.
    Have a nice day,
    FReAK

  • Java teststand - Error 1500 Cannot find class

    Hi everyone,
    I am using TestStand 2010 and Java 1.7.
    I try to add a java class in the Computer example folder, and call the method.
    The java class is simply like below, because I just want to try calling my own java class.
    I have set the Class Path in Start JVM to the directory where the Computer example (which is also the directory where I put my java class) are located.
    TestStand can call the Computer's methods, but not mine (got error Error 1500 Cannot find class). I put my my java method calling among the defaults Computer example calls.
    Furthermore I have read similiar threads but still I cannot solve the error.
    Where is the part I miss, actually? Please share some insights.
    Note: I even try to leave the Class Path empty, but TestStand still can call the Computer's methods. Why?
    public class TestJava {
    public static void main(String[] args) {
    public String returnString(boolean a){
    return "success";
    Solved!
    Go to Solution.

    In order to load a class that is inside a package you have to use the package notation (or modify the example in order to use it). The path to the class is passed directly to the JVM in order to load the class, but really what is needed is the package from the class path including the full path to the class. 
    That means you have to do the following:
    1. Set the class path to the base directory where you built all your classes, if you have the following structure:
    MyFile.java
    builds
    MyPackage
    MyFile.class
    You have to set the classpath to the builds directory
    2. When you configure your steps, you have to set the path to the class in your Java steps to MyPackage/MyFile.class (note separator is a slash, not the usual Windows backslash, so the browse button doesn't quite help with that). 
     Another important thing is that when you set the classpath you are deleting the normal class path in Java, if you are using Java classes from the default libraries you might have to add <jre directory>\lib\rt.jar

  • Warning - Cannot find class de.ewe.ikdb.action.ActionForward

    Hi,
    I'm using external classes e.g. struts as a MVC framework. Using JavaDoc to create the API documentation causes lots of the following warnings:
    warning - Cannot find class de.ewe.ikdb.action.ActionForward
    Actually the class in question is form struts, in the package org.apache.struts.action. As I'm using ant to compile the classes and to generate the documentation so the class path should be ok.
    First I tried the -link option to access the package-list file of struts. This didn't work (but maybe this is a problem due to our firewall).
    So I downloaded the documentation and put it in a local directory and used the -linkoffline option instead. Now the javadoc command works again but I still get these warning messages.
    Does anyone know how to avoid this?
    Regards,
    hedtfeld.

    Hi guys,
    as far as I understand I have to import the classes excplicitly and not with wildcards as my lazy self prefers to do it. It would be nice though to be able to use the wildcard as this is allowed by the java spec ...
    Hope this will help anyone facing the same problem.
    - hedtfeld.

  • Cannot find file bookDB.jar at directory ejb.

    Could anyone help me!!
    I wanna try the sample of J2EE EJB. But I met a problem. According to the BookStore3`s tutorial, the file bookDB.jar ought be under the directory ejb/, but I cannot find it at there.

    I am sorry. I could not read the tutorial clearly. The file bookDB.jar is built at sample Bookstore2, only is used at sample Bookstore3.

  • Cannot find class javax.swing.JOptionPane

    Hello,
    I imported the class
    import javax.swing.JOptionPane;and written as a first line of my code in the form of a .java file.
    but error occurs as : cannot find the class javax.swing.JOptionPane. What should I do.
    Thank you.

    Are you doing something likeimport javax.swing.JOptionPane;
    class Test {
        public static void main(String args[]) {
            JOptionPane.showMessageDialog(null, "Testing",
                    "Testing", JOptionPane.INFORMATION_MESSAGE);
    }Mark

  • Cannot find class CustomerFacadeRemote in NetBeans IDE 5.0 Quick Start Guid

    Hi,
    I am new to Sun Java Studio Enterprise 8.1. I am follwing NetBeans IDE 5.0 Quick Start Guide for J2EE Applications example and got two following errors:
    C:\SunStudioWS\CustomerBook\CustomerBook-war\src\java\web\CustomerDetail.java:41: cannot find symbol
    symbol : class CustomerFacadeRemote
    location: package ejb
    ejb.CustomerFacadeRemote custFacade = lookupCustomerFacadeBean();
    C:\SunStudioWS\CustomerBook\CustomerBook-war\src\java\web\CustomerDetail.java:41: cannot find symbol
    symbol : method lookupCustomerFacadeBean()
    location: class web.CustomerDetail
    ejb.CustomerFacadeRemote custFacade = lookupCustomerFacadeBean();
    2 errors
    C:\SunStudioWS\CustomerBook\CustomerBook-war\nbproject\build-impl.xml:299: The following error occurred while executing this line:
    C:\SunStudioWS\CustomerBook\CustomerBook-war\nbproject\build-impl.xml:141: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 1 second)
    Here is the code:
    * CustomerDetail.java
    * Created on July 23, 2007, 3:27 PM
    package web;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * @author yl
    * @version
    public class CustomerDetail extends HttpServlet {
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet customerDetail</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Servlet customerDetail at " + request.getContextPath () + "</h1>");
    String customerNr = request.getParameter("customer_nr");
    if((customerNr != null) && !(customerNr.equals("")))
    try{
    ejb.CustomerFacadeRemote custFacade = lookupCustomerFacadeBean();
    out.println("Customer's info for nr. " + customerNr + ": " + custFacade.getCustomerInfo(
    Integer.parseInt(customerNr)));
    }catch(javax.ejb.FinderException ex){
    out.println("Customer with nr. " + customerNr +" not found");
    out.println("<form>");
    out.println("Customer number: <input type='text' name='customer_nr' />");
    out.println("<input type=submit value=Select />");
    out.println("</form>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    // </editor-fold>
    private web.ServiceLocator serviceLocator;
    private web.ServiceLocator getServiceLocator() {
    if (serviceLocator == null) {
    serviceLocator = new web.ServiceLocator();
    return serviceLocator;
    private ejb.CustomerFacaderRemote lookupCustomerFacaderBean() {
    try {
    return ((ejb.CustomerFacaderRemoteHome) getServiceLocator().getRemoteHome("java:comp/env/ejb/CustomerFacaderBean",ejb.CustomerFacaderRemoteHome.class)).create();
    } catch(javax.naming.NamingException ne) {
    java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne);
    throw new RuntimeException(ne);
    } catch(javax.ejb.CreateException ce) {
    java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ce);
    throw new RuntimeException(ce);
    } catch(java.rmi.RemoteException re) {
    java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,re);
    throw new RuntimeException(re);
    Thank you very much for any help.
    ylou

    In the code you have posted, some places refer to '.CustomerFacader' while others refer to '.CustomerFacade' leading to issues.
    Also: Have you considered using NetBeans 5.5.1 as an alternative to JSE 8.1?
    http://forum.java.sun.com/thread.jspa?threadID=5192837

  • Cannot find class in same package but in different file

    I have following two source files. Both the file has same package statement as below
    package java.buron.doeacc ;
    But whenever i try to compile File: shoepolish.java ( mainfram.java compiled succesfully before)
    following error message appear
    ..\..\buron\doeacc\shoepolish.java:12: cannot resolve symbol
    symbol : class MainFrame
    location: class java.buron.doeacc.shoepolish
              MainFrame mainFrame = new MainFrame();
    ^
    ..\..\buron\doeacc\shoepolish.java:12: cannot resolve symbol
    symbol : class MainFrame
    location: class java.buron.doeacc.shoepolish
              MainFrame mainFrame = new MainFrame();
    ^
    Please tell me What is the problem and how it can be solved.
    why cannot find the class that are in same package.
    I have JDK 1.3
    FOLLOWING ARE THE TWO FILES
    File: mainframe.java/////////////////////////////////////////////////////////////////////
    package java.buron.doeacc ;
    import javax.swing.* ;
    import java.awt.*;
    import java.awt.event.* ;
    class MainFrame extends JFrame
         private final String APP_NAME = "Shoe Polish";
         // constructor
         public MainFrame()
              super("Shoe Polish");
              setSize(500, 500);
              setVisible(true);
    File : shoepolish.java
    package java.buron.doeacc ;
    import java.io.* ;
    import java.buron.doeacc.* ;
    class shoepolish
         public static void main(String args[])
              MainFrame mainFrame = new MainFrame();

    The javac compiler uses the Classpath to find classes. If your directory structure is c:\myjava\buron\doeacc (for example) then you need to have c:\myjava in the Classpath when you compile. For example javac -classpath c:\myjava MainFrame.java

  • Cannot find class in same directory during compilation

    hi
    i have two file hello.java & hi.java in same directory having simple println statements.
    hello.java
    public class hello {
      public static void main(String[] args) {
        System.out.println("hello");
        new hi();
    }hi.java
    class hi {
      hi() {
        System.out.println("hi");
    }hi.java has compiled
    but when i try to compile hello.java i get error saying "Cannot find symbol class hi"
    i've tried giving classpath pointing to current directory during compilation as
    javac -classpath . hello.java
    but this also does not work.
    Please let me know if i am missing anything?
    thanks in advance...

    The javac compiler uses the Classpath to find classes. If your directory structure is c:\myjava\buron\doeacc (for example) then you need to have c:\myjava in the Classpath when you compile. For example javac -classpath c:\myjava MainFrame.java

  • Cannot find class

    Hi,
    I have very simple problem, but cant find the solution, so if someone can see whats wrong thanks in advance:)
    I have few classes in one folder com\claudeduguay\mailets.
    When i try to compile a class UnavailableMessageBase.java which usses another class in this folder named UnavailableStore, im getting the following error:
    UnavailableMessageBase.java:26: cannot find symbol
    symbol : class UnavailableStore
    location: class com.claudeduguay.mailets.UnavailableMessageBase
    protected UnavailableStore store;
    ^
    UnavailableMessageBase.java:34: cannot find symbol
    symbol : class UnavailableStore
    location: class com.claudeduguay.mailets.UnavailableMessageBase
    store = new UnavailableStore(folder);
    ^
    Class UnavailableStore is compiled.Im ussing package com.claudeduguay.mailets; in both classes.

    After almost 2 years of Java development (per your profile), and you're still having simple classpath issues? Not good.
    Fix your classpath. Obviously it is incorrect, or the compiler wouldn't be complaining that it can't find something. Either that, or you misspelled a class/symbol name.

Maybe you are looking for

  • How to export the data to a  Excel file

    Hi all, How to use the  'EXCEL_OLE_STANDARD_DAT' to export the data from itab to EXCEL file. REPORT  ZT11. data : begin of itab occurs 0,       t1(3)  type c  value 'sag',       t2(3)  type c value 'ntc',       end of itab.       append itab.       w

  • Transfering music from media player to itunes

    I am having trouble transfering music playlists from my media player to itunes. I have tried the 'add a folder' and 'add a file' options and when I click it nothing happens. I have also tried moving the playlists to different files and tryig to add t

  • What to do with indd file that I can't open?

    So I have a file made on Mac and ID CS4. The file is corrupt and I can't open it on the Mac. Tried to open it on PC with CS6, but the same problem appears. At one moment ID even give an Error code 4, but there is no explanation what do that error cod

  • Standard Setup - External IP Update via email?

    I have an iMac G5 with OS X Server 10.5.6 everything stock here and working great. I have it setup as a standard server... offering only the most basic things like file and printer sharing. Is there any setting or and application that will notify via

  • Can we prevent posting in Leading Ledger by closing periods in NLL?

    Is it possible? I have 24 periods in non leading ledger(2 per calendar month) and want to prevent posting in the leading ledger if the posting period is closed in non leading ledger. E.g. if I close periond 1 in non leading ledger which corresponds t