jQuery in Action, 2nd edition
The moose likes Java in General and the fly likes Main class not found Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Main class not found" Watch "Main class not found" New topic
Author

Main class not found

Mohamad Obagi
Ranch Hand

Joined: Oct 25, 2008
Posts: 37
I am trying to run a .jar file on vista but its giving me an error " Main class not found " however the program run on windows XP



Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
That class is missing in the classpath. Check your %CLASSPATH% environment variable, check the current working path, check the -cp or -classpath parameter (which are in fact overriding the %CLASSPATH% environment variable), check the JAR´s manifest. For a more detailed answer, you need to give more detailed information.

After all I would consider this as a "Java in general (Beginner)" question.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
Lucas Franceschi
Ranch Hand

Joined: Nov 10, 2008
Posts: 106

//there's no reason to be aggresive with a fellow rancher, Bauke...

ok, i dont know if it will work, but try doing this:

  • look on the manifest file the exact name of your main class, and try to locate it on your current working path on XP, then try locating the same with the same jar file on vista...
  • be sure that your jar file is the same
  • check your classpath for missing files, files that is in XP's classpath but not on vista's


  • I dont see that as being a solution for you, so, please, i mean, please, provide us some more information, so that you can get helpful reponses, not just guesses....


    Lucas Franceschi
    Software Developer for SGI Sistemas, lukas1596@gmail.com
    Bauke Scholtz
    Ranch Hand

    Joined: Oct 08, 2006
    Posts: 2458
    Lucas Franceschi wrote: //there's no reason to be aggresive with a fellow rancher, Bauke...
    I didn´t shoot him off or so? Were you referring to the last sentence? I don´t know what you think, but how the classpath works is covered by every decent Basic Java book/tutorial. So I don´t see how you see it as agressive.
    Mohamad Obagi
    Ranch Hand

    Joined: Oct 25, 2008
    Posts: 37
    this is the manifest:


    part of Main class

    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24061
        
      13

    The line

    Class-Path: lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar

    means that this JAR file needs files named appframework-1.0.3.jar and swing-worker-1.1.jar in a lib/ directory sitting next to it to run. These things must be installed on the other machine where it works.


    [Jess in Action][AskingGoodQuestions]
    Mohamad Obagi
    Ranch Hand

    Joined: Oct 25, 2008
    Posts: 37
    oh yes it may be the problem :S didn't notice it

    thanks for the help
    Rob Spoor
    Sheriff

    Joined: Oct 27, 2005
    Posts: 19216

    The javaw.exe executable, that will run JAR files when double-clicking, is quite bad in its error messages. Basically, everything that will go wrong is a "main class" error.

    If you ever get this message, run the JAR file from the console:

    This will print out the real stack trace. In your case it would probably print a ClassDefNotFoundError.


    SCJP 1.4 - SCJP 6 - SCWCD 5
    How To Ask Questions How To Answer Questions
     
    I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
     
    subject: Main class not found
     
    Similar Threads
    No main-method
    java.lang.ClassNotFoundException
    why couldn't my project run?
    Threads with Inner Classes
    suspend()