Results 1 to 19 of 19
  1. #1
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default Could not find the main class, program will exit.

    Hey when ever I try and run a .jar file it says Could not find the main class, program will exit. I was reading about the environment variables and found they thought java was in a different directory. I also tried deleting all the java registrys before reinstalling.

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

    Default

    Quote Originally Posted by CourseLanguage View Post
    Hey when ever I try and run a .jar file it says Could not find the main class, program will exit. I was reading about the environment variables and found they thought java was in a different directory. I also tried deleting all the java registrys before reinstalling.
    Does you .jar file have a manifest entry that tells the JVM what the 'main' class is? Environment variables have nothing to do with this.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    Im not shore but this has happened with about 25 different jar files (all i have tried) and they work on my friends computer

  4. #4
    oomrichie is offline Member
    Join Date
    Feb 2011
    Posts
    31
    Rep Power
    0

    Default

    open the jar file with a compression tool like winrar and see if it contains a folder "META-INF" and a file MANIFEST.MF

    the file should look similar to this

    Manifest-Version: 1.0
    Main-Class: package.Main

    if the file has a lactation to the main class try running the jar from cmd

    java -jar "jarfilename.jar"

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

    Default

    Quote Originally Posted by CourseLanguage View Post
    Im not shore but this has happened with about 25 different jar files (all i have tried) and they work on my friends computer
    Can you show us the names of the files in the .jar file? Open it with, say, winzip and check it. Is there a manifest entry?

    kind regards,

    Jos
    Last edited by JosAH; 05-02-2011 at 10:26 AM. Reason: Too slow again ...
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by oomrichie View Post
    open the jar file with a compression tool like winrar and see if it contains a folder "META-INF" and a file MANIFEST.MF

    the file should look similar to this

    Manifest-Version: 1.0
    Main-Class: package.Main

    if the file has a lactation to the main class try running the jar from cmd

    java -jar "jarfilename.jar"
    I extracted it and the manifest.fm said

    "
    Manifest-Version: 1.0
    Rsrc-Class-Path: ./ substance.jar flamingo.jar trident.jar substance-f
    lamingo.jar
    Class-Path: .
    Rsrc-Main-Class: tfcmanager.Main
    Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoa der
    "

    I have already tried through cmd/batch file and it has the same problem.

    and josah the main jar im trying to use is TFCMM v1.5.jar and yes it has a Manifest entry

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

    Default

    Quote Originally Posted by CourseLanguage View Post
    Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoa der

    I have already tried through cmd/batch file and it has the same problem.

    and josah the main jar im trying to use is TFCMM v1.5.jar and yes it has a Manifest entry
    Does that class mentioned in the manifest entry exist somewhere? It's an Eclipse class ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    yes i found JarRsrcLoader.class

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

    Default

    Quote Originally Posted by CourseLanguage View Post
    yes i found JarRsrcLoader.class
    Where did you find it? In the .jar file you mentioned?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    Yes in the extracted files and in that extracted folder it was org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader

  11. #11
    oomrichie is offline Member
    Join Date
    Feb 2011
    Posts
    31
    Rep Power
    0

    Default

    If that exact jar, runs on a different pc and works as you stated previously, i cant imagine the jar is the problem. have you tried reinstalling your jre?

  12. #12
    oomrichie is offline Member
    Join Date
    Feb 2011
    Posts
    31
    Rep Power
    0

    Default

    sorry i see you did reinstall my bad:D

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

    Default

    Quote Originally Posted by CourseLanguage View Post
    Yes in the extracted files and in that extracted folder it was org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader
    (this is going to be a slow thread); and is your JVM complaining about that file? (that it can't find it).

    kínd regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  14. #14
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    It cant find main class but this isnt the jar i have tried alot of programs. Is it possible you could teamviewer me because it would make things faster and easier?

  15. #15
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    Also i think it has to do something with how i use to have java 32 bit and i changed to 64bit and i read another thread and it has something to do with my environment variables

  16. #16
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    I found out that my registry for java is all wrong and so is my environment varibles. So if anyone knows how to add them or revert to default please help?

  17. #17
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    Try reinstalling Java.

  18. #18
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by ra4king View Post
    Try reinstalling Java.
    In my post i said i tried reinstalling alot.

  19. #19
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    Ah I didn't see that. Hmmm this is weird. If it works on another computer, then the JRE is definitely the problem here.

Similar Threads

  1. Could not find the main class, program will exit
    By grottesco in forum New To Java
    Replies: 7
    Last Post: 11-03-2010, 06:51 AM
  2. Replies: 4
    Last Post: 07-29-2010, 02:53 PM
  3. Could not find the main class, program will exit.
    By aryubi in forum New To Java
    Replies: 39
    Last Post: 02-19-2010, 10:02 AM
  4. Could not find the main class. Program will exit.
    By XSROSSITER in forum New To Java
    Replies: 0
    Last Post: 01-30-2010, 04:17 AM
  5. Could not find the main class. Program will exit.
    By Carrier in forum New To Java
    Replies: 1
    Last Post: 04-22-2009, 02:27 AM

Posting Permissions

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