6 Replies Latest reply on Feb 2, 2010 2:43 AM by darrylburke

    Runnable JAR in Eclipse

    843804
      Hi,
      I'm trying to make a runnable JAR in Eclipse, but I don't know how to limit which libraries or other source codes to be included inside. Does anyone know how to do this? The JAR I'm making is 13.6 MB, much bigger than I think it should be.

      Thanks.
        • 1. Re: Runnable JAR in Eclipse
          843804
          You can create a runnable jar file only when u have a public class with main method as a entry point of java Application.Always create runnable jar file when u r using GUI in ur java application.

          Steps which r required in Eclipse for creating runnable jar file as herein after provided

          1-Right click on your project and select export option.A export window will get pop-up.
          2-Select jar file option from the poped-up window which will be in java option of window.
          3-After Clicking JarFile option a new window will get pop-up.
          4-Select the export destination for ur jar file and click next.
          5-After clicking the next a new screen you will see, click on next button again.
          6-Now u will see a new screen which has a field name as "Main Class" browse for your main class of appliaction.main class is once which has main method.
          7-Now select finish.

          U hav done..

          now double click on your created jar n u will see the output.....

          if u hav any other problem...than let me know


          Regards,
          Ashvani Kumar
          • 2. Re: Runnable JAR in Eclipse
            843804
            Well, I know how to do that...the problem is when I make a jar...there are libraries that consist of jars that I want to put inside my new jar...using runnable jar dialog extracts the contents of all the jars and puts them in a runnable jar. But I wanted to figure out how to limit what gets extracted...
            • 3. Re: Runnable JAR in Eclipse
              843804
              i didn't get what u r asking, u r trying to make a runnable jar or do u want to extract a jar. By using jar file there is no need to bundled the libraies into ur runnable jar.these get loaded by classloader of jvm when u double clicked on the jar.
              • 4. Re: Runnable JAR in Eclipse
                843804
                i did what you said, but when i click the file, nothing opens. Is there something that needs to be in the program itself to make it work? And don't give me anything like did you click it twice.
                • 5. Re: Runnable JAR in Eclipse
                  843804
                  yes, it is a problem if the jar file size matters. one way to decrease the jar file size is specifying your import library, it means that you import the specific class from external library instead of the whole library, for example,
                  import javax.swing.tree.TreePath; not import javax.swing.tree.*; after narrow down the imported libraries, you can extract each specific library into your java project, it should be place as the same level as "src",(of cousre it will take you a bit time to do this), or you can let runnable jar dialog doing that for you, but i did not test that way.
                  • 6. Re: Runnable JAR in Eclipse
                    darrylburke
                    lwyelle, welcome to the forum. Please don't post in threads that are long dead. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.

                    Also, your comment is completely wrong and shows that you have no idea how the compiler handles imports. I suggest you post a topic in the [_New to Java forum_|http://forums.sun.com/forum.jspa?forumID=54] asking for help in understanding this.

                    I'm locking this thread now.

                    db