Executable JAR File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amitpathak
    New Member
    • Jan 2007
    • 20

    Executable JAR File

    HI

    Suppose There is a HELLO WORLD Application in java

    When I am running this in a command prompt it is printing the "Hello World"
    in a console window

    Next Time When i make the executable jar of the same application and tried to run the jar at Command prompt
    Nothing happened I mean it is not printing "Hello World".

    I hope you got my question if not please specify.

    Thanks in advance
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by amitpathak
    HI

    Suppose There is a HELLO WORLD Application in java

    When I am running this in a command prompt it is printing the "Hello World"
    in a console window

    Next Time When i make the executable jar of the same application and tried to run the jar at Command prompt
    Nothing happened I mean it is not printing "Hello World".

    I hope you got my question if not please specify.

    Thanks in advance
    1.) How did you make the jar file?
    2.) Is there anything being written to the console when you run it?

    Comment

    • amitpathak
      New Member
      • Jan 2007
      • 20

      #3
      Originally posted by r035198x
      1.) How did you make the jar file?
      2.) Is there anything being written to the console when you run it?

      through ant script.But I am sure that there is no problem in JAR
      because when I tried to create the file for eg(c:sample.txt ) through the same application it worked

      only System.out.prin tln();
      has no effect when I tried to run the jar
      rest all is working

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by amitpathak
        through ant script.But I am sure that there is no problem in JAR
        because when I tried to create the file for eg(c:sample.txt ) through the same application it worked

        only System.out.prin tln();
        has no effect when I tried to run the jar
        rest all is working
        Did you specify the Main-Class attribute in the manifest file?

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by r035198x
          Did you specify the Main-Class attribute in the manifest file?
          My guess is that the .jar file type is associated with the javaw.exe command;
          that version of the virtual machine doesn't start a console window; the OP needs
          to associate his .jar files with the java.exe command instead.

          Assuming the OP is using a Microsoft Windows o.s.

          kind regards,

          Jos

          Comment

          • amitpathak
            New Member
            • Jan 2007
            • 20

            #6
            Originally posted by JosAH
            My guess is that the .jar file type is associated with the javaw.exe command;
            that version of the virtual machine doesn't start a console window; the OP needs
            to associate his .jar files with the java.exe command instead.

            Assuming the OP is using a Microsoft Windows o.s.

            kind regards,

            Jos

            Yes I have specify the main class path in Manifest file
            the thing you are trying to say i m not getting it
            could you be more explainable.Ple ase

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by amitpathak
              Yes I have specify the main class path in Manifest file
              the thing you are trying to say i m not getting it
              could you be more explainable.Ple ase
              If you're using windows then the program that you have associated with jars (default program for running jar files) is javaw.exe instead of java.exe. javaw.exe does not have the console so any output from your program that's supposed to go to the console is not displayed. Simply change the default program for opening jars to be java.exe

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by amitpathak
                Yes I have specify the main class path in Manifest file
                the thing you are trying to say i m not getting it
                could you be more explainable.Ple ase
                MS Windows uses 'file type associations'; when you click on any file, the
                associated program is searched and if found your file is used as an argument
                for the associated program.

                There are two variations for the virtual machine: java.exe and javaw.exe. The
                first opens a console for your jar's standard input, output and error streams.
                The second doesn't open a console. If the second program is associated with
                the .jar file type you can't see a console because none was opened.

                kind regards,

                Jos

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by JosAH
                  MS Windows uses 'file type associations'; when you click on any file, the
                  associated program is searched and if found your file is used as an argument
                  for the associated program.

                  There are two variations for the virtual machine: java.exe and javaw.exe. The
                  first opens a console for your jar's standard input, output and error streams.
                  The second doesn't open a console. If the second program is associated with
                  the .jar file type you can't see a console because none was opened.

                  kind regards,

                  Jos
                  Look who just bought a faster keyboard.

                  Comment

                  • amitpathak
                    New Member
                    • Jan 2007
                    • 20

                    #10
                    Originally posted by r035198x
                    If you're using windows then the program that you have associated with jars (default program for running jar files) is javaw.exe instead of java.exe. javaw.exe does not have the console so any output from your program that's supposed to go to the console is not displayed. Simply change the default program for opening jars to be java.exe

                    Okay Now I understood

                    But I am sorry I donno How to change the default program to run JAR Files
                    Please tell me.

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Originally posted by amitpathak
                      Okay Now I understood

                      But I am sorry I donno How to change the default program to run JAR Files
                      Please tell me.
                      Deepends on which version of windows you're using.
                      On my vista I simply right click the file, and then click change on its "Open with" tab.

                      Comment

                      • JosAH
                        Recognized Expert MVP
                        • Mar 2007
                        • 11453

                        #12
                        Originally posted by r035198x
                        Look who just bought a faster keyboard.
                        :-P but my reply contains more text; so there ;-)

                        kind regards,

                        Jos

                        Comment

                        Working...