8 Replies Latest reply: Jan 19, 2011 5:54 AM by 828589 RSS

    Jar File Problem

    828589
      Hi All,

      My Jar File is running properly through command prompt without any warnings but it is not running when i am double clicking it.
      I have made a runnable jar file through eclipse
      please guide.

      Thanks
      karan
        • 1. Re: Jar File Problem
          JoachimSauer
          user13618054 wrote:
          Hi All,

          My Jar File is running properly through command prompt without any warnings
          What does it do, when it's running?
          but it is not running when i am double clicking it.
          Do you get any error messages? Anything?
          • 2. Re: Jar File Problem
            828589
            No I am not getting any error messages not even warnings ..

            its an application which accesses the database and gives the result in a visualised manner.
            • 3. Re: Jar File Problem
              JoachimSauer
              user13618054 wrote:
              its an application which accesses the database and gives the result in a visualised manner.
              What kind of visualised manner? Does it produce a file? Write to System.out? Open a Swing window? Use AWT? ...
              • 4. Re: Jar File Problem
                828589
                Opens another Swing Window and has a visualized representation of data which is done through IBM JViews.
                • 5. Re: Jar File Problem
                  JoachimSauer
                  Could it be that your application tries to access some resources using relative file paths and breaks if the current directory is not the directory containing your jar file?

                  Try executing your jar from the command line, but don't "cd" to its directory first, instead provide the full path to the .jar file on the command line.

                  I.e. instead of
                  cd \path\to\jarfile
                  java -jar myfile.jar
                  use this:
                  cd \
                  java -jar \path\to\jarfile\myfile.jar
                  (I assume you're using Windows).
                  • 6. Re: Jar File Problem
                    819516
                    His problem doesn't lie with the command line. He's gotten that working, but can't get the double-click action of a jar file to work.

                    The manifest file that's contained in the jar file must be configured properly. You must have the line "Main-Class: fileA" where 'fileA' is the class containing your main function to start the program. Only the name of the class is needed here (doesn't need .java or .class extension).
                    • 7. Re: Jar File Problem
                      JoachimSauer
                      devo1929 wrote:
                      His problem doesn't lie with the command line. He's gotten that working, but can't get the double-click action of a jar file to work.
                      I'm well aware of that. The goal of my instructions is not to get it to work on the command line, but to be able to reproduce the error condition from the command line (where you could see exceptions happening for example).
                      The manifest file that's contained in the jar file must be configured properly. You must have the line "Main-Class: fileA" where 'fileA' is the class containing your main function to start the program. Only the name of the class is needed here (doesn't need .java or .class extension).
                      I assumed (possibly wrongly) that by "running it from the command line" he meant "java -jar myJarFile.jar", which would mean that this is not the problem.

                      @OP: please comment.
                      • 8. Re: Jar File Problem
                        828589
                        There is no error while running like you mentioned it to be...