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 2 of 2 FirstFirst 12
Results 26 to 43 of 43

Thread: Jar file only Works on my computer?

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

    Default Re: Jar file only Works on my computer?

    Quote Originally Posted by Norm View Post
    Has the jre install changed?
    No, you're right, I was misremembering. java.exe is put into windows\system32 or similar.

    Quote Originally Posted by Java Programmer View Post
    So Users need the path and not the classpath?
    So, the PATH will be correct for the user. And the CLASSPATH will be ignored because that's what happens when you run "java -jar".

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

    Default Re: Jar file only Works on my computer?

    ?

    So they need the classpath or they do not need the classpath

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

    Default Re: Jar file only Works on my computer?

    The CLASSPATH setting will be ignored when they run "java -jar YourProgram.jar". So in that sense they don't need it.

    When you run an executable jar the classpath comes from what is specified in the manifest. That's why if your program is not running on another machine we need to see the details - the command, the output, the manifest file, at least.

    If you are testing your program on another machine then installing the JDK on that machine was not a good move. The aim is to run your program on another computer without altering its settings. That's quite possible (and is the "ordinary" state of affairs) and if corrections need to be made, they need to be made to how your are creating the jar file.

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

    Default Re: Jar file only Works on my computer?

    Manifest:
    mainClass.txt
    Main-Class: MessageBoxCreator


    Command Line:
    jar cfmv MessageBoxCreator.jar mainClass.txt MessageBoxCreator.class MainClass.class MainClass$1.class

  5. #30
    Junior Member
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    1
    Thanked 3 Times in 2 Posts

    Default Re: Jar file only Works on my computer?

    Have you created a manifest file?

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

    Default Re: Jar file only Works on my computer?

    Yes:

    Manifest-Version: 1.0
    Created-By: 1.7.0_02 (Oracle Corporation)
    Main-Class: MessageBoxCreator

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Jar file only Works on my computer?

    The OP never posted the console when the jar was executed from the commandline.
    The one posting was for the case where the jar file was not seen by the java command, probably because the OP was in the wrong folder or misspelled the name of the jar file. Hard to say.

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

    Default Re: Jar file only Works on my computer?

    This happend a month before when i exported it from eclipse?

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

    Default Re: Jar file only Works on my computer?

    Quote Originally Posted by Norm View Post
    The OP never posted the console when the jar was executed from the commandline.
    The one posting was for the case where the jar file was not seen by the java command, probably because the OP was in the wrong folder or misspelled the name of the jar file. Hard to say.

    Ive Check My Spelling and nothing is misspelled.
    I Do Not Understand What this means, ive made the jar file 5 times and i kept getting the same thing!! D:
    Last edited by Java Programmer; January 7th, 2012 at 07:39 PM.

  10. #35
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Jar file only Works on my computer?

    When are you going to try what I suggested in post #3 & #11?

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

    Default Re: Jar file only Works on my computer?

    i no longer have the error?
    not to disrespect you but i did already just without everything, like the same exact example you posted

  12. #37
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Jar file only Works on my computer?

    I got the same error message as you reported when I entered an madeup jar file name. If the file had been there you get a different error message. My assumption was that either the file was in another folder or the name was misspelled. Here's what I get when java finds a jar without a manifest:

    Microsoft Windows XP [Version 5.1.2600]

    D:\JavaDevelopment\Testing\ForumQuestions5>java -jar hsa.jar
    Failed to load Main-Class manifest attribute from
    hsa.jar

    D:\JavaDevelopment\Testing\ForumQuestions5>
    My conclusion was that a thorough test had not been done.

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

    Default Re: Jar file only Works on my computer?

    No In Post #11


    Microsoft Windows XP [Version 5.1.2600]

    D:\JavaDevelopment\Testing\ForumQuestions7>java -jar asdfasdf.jar
    Unable to access jarfile asdfasdf.jar

    D:\JavaDevelopment\Testing\ForumQuestions7>

    Was your example, everything was correct and when i double clicked it it didnt open either

  14. #39
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Jar file only Works on my computer?

    You get better error messages when you manually enter the java -jar command.
    I don't remember that you did that, copied the command prompt window and posted it.

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

    Default Re: Jar file only Works on my computer?

    #6
    "Unable to access jarfile MessageBoxCreator.jar "
    Was My Error..

  16. #41
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Jar file only Works on my computer?

    That can mean there is no jar file with that name in that folder.

    But you never posted the console window contents that shows the name of the folder.

    You never did a dir command to show what was in the folder.

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

    Default Re: Jar file only Works on my computer?

    everthing was correct i did it 5 times and changes cd

  18. #43
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Jar file only Works on my computer?

    everthing was correct
    Famous words.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. I have no idea how this works.
    By GeneralPihota in forum Algorithms & Recursion
    Replies: 3
    Last Post: December 29th, 2011, 09:55 PM
  2. It works!!! eureka!!! Java...Day 12.
    By Spidey1980 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: August 18th, 2011, 09:41 PM
  3. GUI Only Works Sometimes
    By bgd223 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 12th, 2011, 08:08 AM
  4. jar file works on XP but not on Linux
    By cl2606 in forum Java Theory & Questions
    Replies: 1
    Last Post: June 10th, 2011, 09:19 AM
  5. Making computer independent file path
    By Javabeginner in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: September 2nd, 2010, 03:56 PM