creating a jar file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • po0oker
    New Member
    • Mar 2008
    • 4

    creating a jar file

    hi

    i would like to create an executable jar file that runs by double clicking ..

    could someone please explain it step by step


    thank you in advance
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    If your .jar contains a class with a main and the main point is set to that class (IDEs do this automatically, or at least Netbeans does), it should run automatically on doubleclick. Sun's Java Tutorials have all the info you need.

    Comment

    • po0oker
      New Member
      • Mar 2008
      • 4

      #3
      thx for your help .. yeah i did create one but for some reason i keep getting this error and i couldn't find an answer to it anywhere ...

      the error is
      ""could not find the main class . program exit "

      thx again

      Comment

      • want2beScripter
        New Member
        • Mar 2008
        • 2

        #4
        Originally posted by po0oker
        thx for your help .. yeah i did create one but for some reason i keep getting this error and i couldn't find an answer to it anywhere ...

        the error is
        ""could not find the main class . program exit "

        thx again
        you have to have the files.... like if you made it through netbeands IDE you'd have files so make sure the files are at the same location as the jar

        Comment

        • po0oker
          New Member
          • Mar 2008
          • 4

          #5
          Originally posted by want2beScripter
          you have to have the files.... like if you made it through netbeands IDE you'd have files so make sure the files are at the same location as the jar
          which files ?? i placed everything in the same directory

          Comment

          • po0oker
            New Member
            • Mar 2008
            • 4

            #6
            ok maybe the problem is because my main class is linked with other classes .. could this be the reason of getting the error ?

            Comment

            • sukatoa
              Contributor
              • Nov 2007
              • 539

              #7
              Originally posted by po0oker
              which files ?? i placed everything in the same directory
              if the jar tool is already been set in the classpath....

              Follow the pattern....

              jar -cmf manifest.mf NameOfYourJarfi le.jar *.class

              If the jar tool have not been set on classpath...
              Put all your class in the bin folder....

              Do it in CMD in Win, or terminal in linux....

              -cmf can be found on jar help....

              Manifest tutorials are on the web..... ;-)


              Sukatoa.....

              Comment

              • gaya3
                New Member
                • Aug 2007
                • 184

                #8
                Originally posted by po0oker
                ok maybe the problem is because my main class is linked with other classes .. could this be the reason of getting the error ?

                Hi,
                I would like to add one more point to sukatoa ,
                You have to write Manifest.txt file in that you have mention like
                "Main-Class: yourPackage.you rClassName"
                Then you follow the below procedure..
                --> jar cfm JarName.jar Manifest.txt yourPackage/*.class
                --> java -jar JarName.jar

                Hope it helps you.:-)

                -Thanks & Regards,
                Hamsa

                Comment

                Working...