Results 1 to 13 of 13
  1. #1
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default jar file problem

    hello ,
    i'm working on a simple java application..
    whenever i create object of the main class in main() method
    and try to run jar file from command prompt it' giving the error
    "NoClassDefinitionFound".
    otherwise the jar file is working absolutely fine.
    but, my requirement is that i want to make object of same class in main()
    and call one of it's non static method..

    can anyone tell me whr i'm going wrong.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    You'll need to post some code, and the full error.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes you must provide more details about the your question.

    my requirement is that i want to make object of same class in main()
    Is that the same class which contain the main method?

  4. #4
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    1st of all sorry for not posting the code in code tags .
    bcoz code tag button is not working in my browser . i don't know why.
    hre is my code...
    --------------------------------------------------------------------------
    public class Main
    {
    public static void main(String[] args)
    {
    Main obj=new Main();
    obj.doConstructorLogic();
    }

    private class giveConnection
    {
    .........
    }

    private class servicediscovery
    implements DiscoveryListener
    {
    .........
    }

    private class devicediscovery
    implements DiscoveryListener
    {
    ........
    }

    public void doConstructorLogic()
    {
    System.out.println("In mains constructor logic");
    serviceURL = null;
    FinalUrl = null;
    UStr = null;
    cs = null;
    hs = null;
    testurl = null;
    i = 0;
    cnt = 0;
    SrNo = -1;
    Send_What_flag = "";
    pin_cnt = 0;
    error_cnt = 0;
    redir_errrmsg_cnt = 0;
    BT_Dev_cnt = 0;
    try
    {
    local = LocalDevice.getLocalDevice();
    discoveryAgent = local.getDiscoveryAgent();
    System.out.println((new StringBuilder()).append("Local Device: ").append(local.getFriendlyName()).append(" : ").append(local.getBluetoothAddress()).toString()) ;
    local.setDiscoverable(0);
    giveConnection connobj = new giveConnection();
    try {
    conn = connobj.ConnectionType4Provider();
    } catch (SQLException ex) {
    ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
    ex.printStackTrace();
    }
    try
    {
    try {
    connobj.Empty_BT_Table(conn);
    } catch (SQLException ex) {
    ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
    ex.printStackTrace();
    }
    try {
    connobj.Empty_BT_Confirmation(conn);
    } catch (SQLException ex) {
    ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
    ex.printStackTrace();
    }
    int n = connobj.Enter_info(conn);
    System.out.println((new StringBuilder()).append("n :").append(n).toString());
    }
    catch(SQLException ex)
    {
    ex.printStackTrace();
    }
    catch(ParseException ex)
    {
    ex.printStackTrace();
    }
    }
    catch(Exception e)
    {
    message = "Local Device Not Found";
    return;
    }
    devicediscovery dd = new devicediscovery();
    }

    }
    -------------------------------------------------------------------------


    i can not make doConstructor Logic() method static bcoz all the variables it uses are nonstatic and due to some other limitations..
    this code is working very properly in netbeans 5.5 ide but whenever i try to run the application from command prompt , its throwing the following error.

    "
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/bluetooth/UUID
    at test_bt.Main.<init>(Main.java:950)
    at test_bt.Main.main(Main.java:54)
    "

    line 54 is that whr i'm creating Main's instance.

    i'm using following command to run the file..

    java -jar "Demo_BT.jar"

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    DO NOT use Main for the class name in Java. It's reserved word in main method, entry point. Change it as soon as possible, very bad practice.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  7. #7
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    change the class name ,
    but no difference . it's giving same error.

  8. #8
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    doConstructorLogic() is located in same Main class, which name now i've changed.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by abhijit View Post
    change the class name ,
    but no difference . it's giving same error.
    That's nothing to do with the error. I just said it's not good practice to use that word, reserved word. May cause many issues.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by abhijit View Post
    doConstructorLogic() is located in same Main class, which name now i've changed.
    If so, how you place classes within that Main class?

  11. #11
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    i've already shown that in the code snippet provided earlier..
    all the classes within main class are private..

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    Um:
    "NoClassDefFoundError: javax/bluetooth/UUID"
    It's got nothing to do with Main...which is why I asked for the actual exception.
    Which line is line 950?

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by abhijit View Post
    i've already shown that in the code snippet provided earlier..
    all the classes within main class are private..
    Yes, it's clear to me. The thing is when I looking at the code, seems part of them are missing, means the parenthesis.

Similar Threads

  1. Jar File Problem
    By Moncleared in forum New To Java
    Replies: 10
    Last Post: 10-18-2009, 07:43 AM
  2. jar file problem
    By nishant.4545 in forum New To Java
    Replies: 1
    Last Post: 07-03-2009, 08:36 PM
  3. problem with jar file
    By biba84 in forum Advanced Java
    Replies: 7
    Last Post: 11-09-2008, 06:46 PM
  4. problem - using a jar file
    By jon80 in forum New To Java
    Replies: 6
    Last Post: 07-07-2008, 07:49 AM
  5. problem with jar file pls help
    By jinu5 in forum New To Java
    Replies: 0
    Last Post: 08-15-2007, 10:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •