Results 1 to 10 of 10
  1. #1
    Shravee is offline Member
    Join Date
    Dec 2012
    Posts
    8
    Rep Power
    0

    Question Exception raised only in CMD

    Dear All,

    I have a program which runs perfectly fine in Eclipse. however, the same program after exporting to jar in desktop and then executing in cmd gives exception.

    why is this difference. could you please help.

    in eclipse. it is built up 1.6 JDK and run using 1.6 JRE.
    in CMD, it runs by 1.7 JRE.

    can this JRE version make a difference. Technically should not i believe.


    please advise.

    --shravee

  2. #2
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: Exception raised only in CMD

    perhaps start by saying what the error is that you are getting? ;)

    and the code where it goes wrong, and all code that is relevant to the problem

  3. #3
    Shravee is offline Member
    Join Date
    Dec 2012
    Posts
    8
    Rep Power
    0

    Question Re: Exception raised only in CMD

    Quote Originally Posted by liluma View Post
    perhaps start by saying what the error is that you are getting? ;)

    and the code where it goes wrong, and all code that is relevant to the problem
    error or exception --> I get class not found exception and classdefnotfound error. I dont know what does this mean.

    code --> written below.
    --------------------------------------- start code --------------------
    void man (){

    try {

    set of lines

    --- problemline -----

    }catch {}

    -------------------------------------- end code -----------------------

    basically in the set of lines im iterating from 1 to n items. in my eclipse, the iteration completes without any error and is successfull. however when done in cmd, it does not even run the first item at all.

    so i believe there is no problem in code but in usage of jar in cmd prompt.

    kindly advise

    --shravee

  4. #4
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Exception raised only in CMD

    Could you copy the exact error code, and the exact code that is giving errors?

  5. #5
    Shravee is offline Member
    Join Date
    Dec 2012
    Posts
    8
    Rep Power
    0

    Default Re: Exception raised only in CMD

    Exception raised only  in CMD-citi_error1.jpg

    HI zFollette

    I have attached the error as requested. please note the same program is perfectly fine when executed in eclipse

    --shravee

  6. #6
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    264
    Rep Power
    2

    Default Re: Exception raised only in CMD

    InvocationTargetException is not really the cause.
    as it says caused by: java.lang.NoClassDefFoundError.

    That is when the JVM cant load a class, It existed when it was compiled, but not longer. you probably failed to place it in the classpath.

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,541
    Blog Entries
    7
    Rep Power
    20

    Default Re: Exception raised only in CMD

    The .jar file just isn't complete; Eclipse runs the individual classes, found in its workspace, but outside, the classes (resources) aren't present in the .jar file.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Exception raised only in CMD

    I don't know exactly what code caused that, since you didn't post it. I assume that you are calling
    Java Code:
    this.getClass().getClassLoader().getRecource("");
    Or something like that. This would throw that error, provided the resource cannot be found.

  9. #9
    Shravee is offline Member
    Join Date
    Dec 2012
    Posts
    8
    Rep Power
    0

    Question Re: Exception raised only in CMD

    Dear All,

    the solution is found.

    i created a new project now in eclipse and a new java class file and copied the same program from the existing/old project to this new project. It worked both in eclipse and also when exported to jar and ran in CMD prompt.

    differences : i am using few third party libraries. in my old or existing project, I earlier created user defined libs like lib1, lib2, lib3 and have added external jars respectively.

    however, in case of my new project, I did not create any user defined libs and simply added the external libs from build path. this way, eclipse has created the default library " referenced libraries" and all the added external libs were dumped here.

    although, the root cause is identified, please help me to understand how does this make a difference in execution at Command prompt only.

    --shravee

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,541
    Blog Entries
    7
    Rep Power
    20

    Default Re: Exception raised only in CMD

    Sigh, as I wrote before: your .jar file is missing a resource: it uses an external .jar file where the org.xml.whatever class is (see the exception stack trace); you should mention in on a 'Class-Path:' line in your manifest. Eclipse can find those classes because you have put it on the classpath, your .jar file is missing that classpath.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 7
    Last Post: 01-20-2012, 09:44 PM
  2. Replies: 5
    Last Post: 02-14-2011, 11:39 PM
  3. NumberFormatException raised
    By venkatallu in forum New To Java
    Replies: 1
    Last Post: 06-02-2009, 09:27 PM
  4. Replies: 1
    Last Post: 03-08-2008, 06: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
  •