1 Reply Latest reply: Oct 17, 2006 5:51 PM by 807607 RSS

    importing jar files?

    807607
      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

      HOW?????

      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?
          807607
          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();