Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 26

Thread: Jar File Not Working.

  1. #1
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Exclamation Jar File Not Working.

    Sorry If This Is In The Wrong Spot I'm New Here.

    I made a jar File Using CMD/Command Lines "jar cfmv example.jar examlpeMainifest.txt example.class"

    But when i open the jar file nothing happens at all?
    i coded it in eclipse and it worked fine on a exported jar file but when i did it using javac it didn't?

    I Really Need help, if you need anything about my code i will send it asap.


  2. #2
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    it is not working? actually its working(just an assumption), running a java program withing an IDE and without it is a different scenario. you just cant see whats going on... a forum mate helped me with that.. i just forget how to run it manually in CMD line to see the error your jar file is encountering, let me look on the forum itself with my previous post. and it might give you the thing that you want.

  3. #3
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    Okay, Thank You.
    But it is a JFrame By The Way.

  4. #4
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    and please clarify the problem, what is it that is NOT WORKING?, how does it not work?, does a window open and it doesnt do what you expect? or when you clicked it nothing really happens?

  5. #5
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    Quote Originally Posted by chronoz13 View Post
    and please clarify the problem, what is it that is NOT WORKING?, how does it not work?, does a window open and it doesnt do what you expect? or when you clicked it nothing really happens?
    Nothing at all happens lol, dont know how to explain nothing..
    i was expecting my jframe it pop up like before but all it did was nothing?

  6. #6
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    lol man, look at this, i hope this help you.. this was my post year ago and Norm a forum mate helped me with it, i solved it by running the jar file outside the IDE itself, and BOOM, i saw tons of Exceptions that i didnt encounter inside the IDE,

    http://www.javaprogrammingforums.com...ing-jar-2.html

  7. #7
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    i would like to add, for example case sensitivity with external files like images, a small .png is different with an uppercase .PNG when you run it OUTSIDE your IDE, i really dont know why..

    you might as well look at the similar threads below your thread posts, scroll down your screen below, you will see similar thread titles, that can enhance your search

  8. #8
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    how do i copy whats in my CMD on windows xp. .-.

  9. #9
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    Error.jpg

    This is my error. :e

  10. #10
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    click on the very top left of the CMD window, you can see CMD options, like edit, copy paste.

  11. #11
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    so thats the problem.

    this one might help you man

    http://javarevisited.blogspot.com/20...eption-in.html
    Last edited by chronoz13; January 6th, 2012 at 11:56 PM.

  12. #12
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    C:\Documents and Settings\Owner\Desktop\MessageBox\Files>jar cfmv MessageBoxCrea
    tor.jar mainClass.txt MessageBoxCreator.class MainClass.class
    added manifest
    adding: MessageBoxCreator.class(in = 445) (out= 329)(deflated 26%)
    adding: MainClass.class(in = 1641) (out= 846)(deflated 48%)

    C:\Documents and Settings\Owner\Desktop\MessageBox\Files>java -jar MessageBoxCre
    ator.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: MainClass$1
    at MainClass.<init>(MainClass.java:60)
    at MessageBoxCreator.main(MessageBoxCreator.java:6)
    Caused by: java.lang.ClassNotFoundException: MainClass$1
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more

  13. #13
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    i think i found my problem: Classpath For Java?

  14. #14
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    yeah i suppose, the system cant locate your classes properly

  15. #15
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    CLASSPATH

    C:\Program Files\Java\jdk1.7.0_02\bin

    I'm Confused. :[]
    Last edited by Java Programmer; January 7th, 2012 at 12:09 AM.

  16. #16
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    its not about your JDK, your system cannot locate the classes properly that is why you get NoClassDefFoundError, make sure they are set on the correct folder when you run your jar via CMD

  17. #17
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    C:\Documents and Settings\Owner\Desktop\MessageBox\Files>java -jar MessageBoxCreator.jar Is Where Its Located?

  18. #18
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    Quote Originally Posted by chronoz13 View Post
    its not about your JDK, your system cannot locate the classes properly that is why you get NoClassDefFoundError, make sure they are set on the correct folder when you run your jar via CMD
    I Do Thank you For The Help, I've Followed Several Tuts And Snippets On How To Create Jar Files But I Don't Understand Them, Thanks For Trying I Just Don't Understand.

  19. #19
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    np, its a little bit complicated, im not that much of an expert, i can only share what i had once before. sorry if i cant make you resolve your issue, but be positive, its just there

  20. #20
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    Quote Originally Posted by chronoz13 View Post
    np, its a little bit complicated, im not that much of an expert, i can only share what i had once before. sorry if i cant make you resolve your issue, but be positive, its just there
    been trying to make a sharable jar file for a month
    time to stop being Positive.

  21. #21
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    ok let me share the only thing left in my mind, try to re-compile or re-build (clean and build) all, NoClassDefFoundError is being thrown when JVM cant load the class although it can see it(although its not the correct statement to say it),

  22. #22
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Jar File Not Working.

    Quote Originally Posted by Java Programmer View Post
    C:\Documents and Settings\Owner\Desktop\MessageBox\Files>jar cfmv MessageBoxCrea
    tor.jar mainClass.txt MessageBoxCreator.class MainClass.class
    added manifest
    adding: MessageBoxCreator.class(in = 445) (out= 329)(deflated 26%)
    adding: MainClass.class(in = 1641) (out= 846)(deflated 48%)

    C:\Documents and Settings\Owner\Desktop\MessageBox\Files>java -jar MessageBoxCre
    ator.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: MainClass$1
    at MainClass.<init>(MainClass.java:60)
    at MessageBoxCreator.main(MessageBoxCreator.java:6)
    Caused by: java.lang.ClassNotFoundException: MainClass$1
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more
    The error message is saying that it cannot find a class called MainClass$1. And - sure enough! - you didn't add it when you created the jar file.

    Try putting all the class files into the jar with:

    C:\Documents and Settings\Owner\Desktop\MessageBox\Files>jar cfmv MessageBoxCreator.jar mainClass.txt *.class

    MainClass$1 will be some anonymous inner class within MainClass - a button handler for example. At any rate it will be created when you compile your program and it has to be added to the jar file.

  23. The Following 2 Users Say Thank You to pbrockway2 For This Useful Post:

    chronoz13 (January 7th, 2012), Java Programmer (January 7th, 2012)

  24. #23
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Jar File Not Working.

    i hope it solves his problem, now i see myself again, being so dependent on my IDE, i use to forget the things im getting along the road. thanks for that mate, now i have a bunch of tabs in my browser again LOL,

  25. The Following User Says Thank You to chronoz13 For This Useful Post:

    Java Programmer (January 7th, 2012)

  26. #24
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    Quote Originally Posted by pbrockway2 View Post
    The error message is saying that it cannot find a class called MainClass$1. And - sure enough! - you didn't add it when you created the jar file.

    Try putting all the class files into the jar with:

    C:\Documents and Settings\Owner\Desktop\MessageBox\Files>jar cfmv MessageBoxCreator.jar mainClass.txt *.class

    MainClass$1 will be some anonymous inner class within MainClass - a button handler for example. At any rate it will be created when you compile your program and it has to be added to the jar file.

    OMG THANK YOU THANK YOU THANK YOU THANK YOU~!!!!!!!
    I Thought that was just a random file created by my complier!!!!!
    so i kept deleting it <3 THANK YOU SO MUCH!!!

  27. #25
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Default Re: Jar File Not Working.

    And Thank You Too@!

Page 1 of 2 12 LastLast

Similar Threads

  1. [SOLVED] Working on Win 7 and not on XP
    By shaumux in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 4th, 2011, 05:36 PM
  2. Openning a file in Native Application not Working
    By wagb278 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 8th, 2011, 02:31 PM
  3. Urgent - File exist nor working
    By Bagzli in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 2nd, 2011, 04:09 AM
  4. Jar Executable File Not Working
    By Kimimaru in forum Java Theory & Questions
    Replies: 6
    Last Post: October 15th, 2010, 09:32 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM