1 Reply Latest reply on Oct 17, 2006 10:51 PM by 807607

    importing jar files?

      i need to reach a couple of classes in a jar file that's located in the same folder as the program i'm running. let's call the jar file files.jar

      i am able to run the program with the files inside extracted

      i need to be able to run it without the extraction


      i'm so frustrated

      i've tried:

      import files.jar;
      import files.jar.Array;
      import Array.files;
      infinite attempts....

      please help

      what line of code am i suppose to use?
        • 1. Re: importing jar files?
          You don't use import statements to grab stuff in jar files. import statements are just used to tell the compiler the full package names of classes.

          To use a jar file, just put it in your classpath. For example, you might do it like this:
          java -cp .;myJar.jar MyMainClass
          or other ways, depending on what you're trying to accomplish.

          You may use import statements if you want to alias long full class names. For example if the class "Documentation" is in the "i.dont.like.to.read.the" package, then you could do:
          import i.dont.like.to.read.the.Documentation;
          so that later in your code you could use Documenation without the full package name, like this:
          Documentation notForMe = new Documentation();