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 44 of 44

Thread: Jar Executable File

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    Will it even let it ...
    Depends on the IDE.

  2. The Following User Says Thank You to Norm For This Useful Post:

    javapenguin (June 17th, 2010)

  3. #27
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    Why is it even asking the user to, repeatedly too unfortunately, to enter the size of the grid? I never told it to do that in the exception, did I?

    Enter a value that is an integer, i.e. not a decimal
    java.util.InputMismatchException
    Enter the size of the grid.

  4. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    I knew it! You have a ghost that is changing your code when you turn your head.

    InputMismatchException
    You must enter the type of data that the program expects.
    And the program MUST handle ANY user input.

  5. The Following User Says Thank You to Norm For This Useful Post:

    javapenguin (June 17th, 2010)

  6. #29
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    Quote Originally Posted by Norm View Post
    I knew it! You have a ghost that is changing your code when you turn your head.


    You must enter the type of data that the program expects.
    And the program MUST handle ANY user input.
    It's not that it doesn't handle it, it's that it won't stop handling it.

  7. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    Look at this code. Make a small test program and execute it. Enter chars vs digits sometimes.
          try {
            System.out.print("Enter an integer:");
            int x = s.nextInt();
            System.out.println("got x=" + x);
          }catch(InputMismatchException x) {
            System.out.println("error " + x);
            String ln = s.nextLine();   // remove the  invalid stuff
            System.out.println("ln=" + ln);
          }
          try {
            System.out.print("Enter another integer:");
            int x = s.nextInt();
            System.out.println("got x1=" + x);
          }catch(InputMismatchException x) {
            System.out.println("error1 " + x);
            String ln = s.nextLine();  // remove the  invalid stuff
            System.out.println("ln1=" + ln);
          }
       }

  8. The Following User Says Thank You to Norm For This Useful Post:

    javapenguin (June 17th, 2010)

  9. #31
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    Quote Originally Posted by Norm View Post
    Look at this code. Make a small test program and execute it. Enter chars vs digits sometimes.
          try {
            System.out.print("Enter an integer:");
            int x = s.nextInt();
            System.out.println("got x=" + x);
          }catch(InputMismatchException x) {
            System.out.println("error " + x);
            String ln = s.nextLine();   // remove the  invalid stuff
            System.out.println("ln=" + ln);
          }
          try {
            System.out.print("Enter another integer:");
            int x = s.nextInt();
            System.out.println("got x1=" + x);
          }catch(InputMismatchException x) {
            System.out.println("error1 " + x);
            String ln = s.nextLine();  // remove the  invalid stuff
            System.out.println("ln1=" + ln);
          }
       }
    How will it know which x you're talking about?

    int x = s.nextInt();

    InputMismatchException x

    System.out.println("error " + x);

    Also, it will run exceptions, it just keeps going, i.e.

    InputMismatchException
    InputMismatchException
    InputMismatchException
    InputMismatchException
    etc

    It probably is because I'm having it do everything all over as I have the option to play again.

    Unless, do you mean my stuff like this:

    String ln = s.nextLine() should be removed?

  10. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    Did you try my code in a program?

  11. The Following User Says Thank You to Norm For This Useful Post:

    javapenguin (June 17th, 2010)

  12. #33
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    Not yet, but I figured out that it's only the Input Mismatch Exception that's causing the problem. The other two Eclipse claims are causing errors aren't. Actually, I see what you meant, though how come I didn't need to have console.nextLine for my two other exceptions?

  13. #34
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    Microsoft Windows [Version 6.0.6001]
    Copyright (c) 2006 Microsoft Corporation. All rights reserved.

    C:\Users\Paul>java -jar battleship2.jar
    Unable to access jarfile battleship2.jar

    And now:

    Microsoft Windows [Version 6.0.6001]
    Copyright (c) 2006 Microsoft Corporation. All rights reserved.

    C:\Users\Paul\Documents>java -jar battleship game 2.jar
    Unable to access jarfile battleship

    C:\Users\Paul\Documents>java -jar battleship2.jar
    Invalid or corrupt jarfile battleship2.jar

    C:\Users\Paul\Documents>

  14. #35
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    Ok, code works now but still won't open. I told the desktop application to open with command prompt.

  15. #36
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    C:\Users\Paul\Documents>java -jar battleship2.jar
    Invalid or corrupt jarfile battleship2.jar
    The java program doesn't like your jar file.
    Can you open it using a program that can read zip files and see if its corrupted?
    If you can open it, look at the manifest file and see if it is formated correctly.

  16. The Following User Says Thank You to Norm For This Useful Post:

    javapenguin (June 18th, 2010)

  17. #37
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    It may possibly be corrupted, but it does like it when I enter the name of the file in the command prompt or something like that, though it only shows the copyright.

  18. #38
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    I used Eclipse.

  19. #39
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    Can you open it using a program that can read zip files and see if its corrupted?
    If you can open it, look at the manifest file and see if it is formated correctly.
    Do you have a program that can open a zip file?

  20. #40
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    I might. Name some that will. Actually I do, but don't know their names.

  21. #41
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    On WinXP XP will open zip files. Rename the file by adding .zip to the end.

  22. The Following User Says Thank You to Norm For This Useful Post:

    javapenguin (June 18th, 2010)

  23. #42
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    I have Vista.

  24. #43
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Jar Executable File

    Try it. No idea how vista works.

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

    javapenguin (June 18th, 2010)

  26. #44
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Jar Executable File

    Anyway, is there way to make these jars so they can be sent to others more easily instead of running into a lot of technical errors sending them in email?

    And is it possible to create a class that has one, undefined, JButton, or better, yet has an int in the constructor that determines the number of JButtons created, and a thing in the constructor to make a JScrollPane with a JTextArea and at least one JMenu that would create an int number of JMenuItems with another int number of submenuitems all in the constructor?

    It will be class JComboPane.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [SOLVED] Executable .jar file isn’t launched after being double-clicked
    By voltaire in forum Java Theory & Questions
    Replies: 6
    Last Post: May 18th, 2010, 03:37 PM
  2. Making executable JAR more "executable"
    By ni4ni in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 1st, 2010, 01:19 PM
  3. How to change File Type of a File Using java
    By akash169 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: March 31st, 2010, 02:58 AM
  4. Inputing file (.txt) and finding the highest number in the file
    By alf in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 15th, 2010, 09:11 AM
  5. Replies: 8
    Last Post: January 6th, 2010, 09:59 AM