4 Replies Latest reply: Jan 16, 2010 12:49 AM by 843804 RSS

    Adding JAR file to netbeans library??

    843804
      Hi everyone. I'm using NetBeans 5.5. I have a new a jar file that i want to include in my program. How do i add it to the library?
        • 1. Re: Adding JAR file to netbeans library??
          843804
          well when you have net beans open:
          go to the project view on your left
          then right click on the library option,
          then click add JAR/Folder option.
          Then choose what you want to add. This should work. I think! :)
          • 2. Re: Adding JAR file to netbeans library??
            843804
            Hi. I tried adding jar files on the library but when I compile my program, it says that one class is undefined.. I added the class in the library.. it is included on the jar file I added.
            • 3. Re: Adding JAR file to netbeans library??
              843804
              In NetBeans 6.5.1, I have added some jar(to be specific [log4j-1.2.15.jar|http://gpraveenkumar.wordpress.com/2009/05/01/download-and-install-log4j-log-for-java/] ) files by importing them. I have written a post on how I imported these in my blog. Check out, may be they are helpful.

              [http://gpraveenkumar.wordpress.com/2009/06/17/abc-to-import-a-jar-file-in-netbeans-6-5/|http://gpraveenkumar.wordpress.com/2009/06/17/abc-to-import-a-jar-file-in-netbeans-6-5/]

              G Praveen Kumar
              [http://gpraveenkumar.wordpress.com|http://gpraveenkumar.wordpress.com]

              Edited by: gpraveenkumar on Jun 29, 2009 7:14 AM
              • 4. Re: Adding JAR file to netbeans library??
                843804
                You rightclick your project, then properties, and there libraries and add Project, if you want another NetBeans project to be compiled with this one. If you have compiled stuff already, you can add it with another button called add Jar. The later one won't link any NetBeans project to be compiled, but each will create a lib folder in your dist folder where your .jar file is, and put everything there, then add it relatively into the classpath of your jar. So you can link external libraryes this way.

                Another way to add other folders under sources in the properties window, then each folder will be included into your jar file, but they will share the same classpath. This is only a problem if they use "default package" what isn't recommended anyway.

                The dirty hack of the two can be if you set the compile dependency, then add the other project's dist folder into your projects' source folders. Then you'll get another jar inside yours. This usually isn't useful because you can't access it by default, but if you have to send it over the web or write it out into the disk instead of executing it right away, you can get an included jar as a data stream very easily this way. This combination is not supported officially and may fail!
                In case this hack fails, you can always use a zip program to copy a jar into another one directly.