Results 1 to 2 of 2
  1. #1
    RichW is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default Embarrassingly basic and bad question

    I am googled out in trying to figure out something that is going to be quite embarrassing, I am sure.

    I write programs for my use only, usually just filtering out large amounts of data from a series of flat files and then spitting out the results. Sometimes I do a lot of analysis, number crunching, etc.

    I am not a real programmer and I have only used the standard java library. I decided for some of my pattern recognition to download some prebuilt stuff from apache commons (specifically apache commons math).

    Let's say I have a huge depository of files, say c:\java\patternanalysis\

    (I am in windows and no, I didn't create a project, separate source/class directories, etc and I know that is poor programming). I extracted the jar that I wanted and now I have c:\java\patternanalysis\org\apache\commons\math... (once in math there are lots of classes and directories)...

    Here is the pathetic part, how do I use an import statement to use this?

    Oh I don't and can't see myself ever using an IDE, I use notepad++ just for some color coding. Don't know if that is important.

    Thank you in advance,

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    You import as yu would anything from the standard libraries:

    Java Code:
    import org.apache.commons.math.SomeClass;

    It is when you compile or run your program that the fun starts.

    I don't know exactly what you meant by saying you extracted the jar. Take the zip download file (like and put the jar file (commons.math-2.1.jar) somewhere you can find it later. But don't extract the contents of this jar file.

    When you compile or run a Java program you will need to specify the locations of classes so that the import statement will work at comple time and so that the actual classes will be located at runtime. Typical compile and run commands to be executed in the directory that contains the packages *you* have written might look like:

    Java Code:
    javac -cp .;\jars\commons-math-2.1.jar main\
    java -cp .;\jars\commons-math-2.1.jar main.MyApp

    The -cp switch expects a ; separated list of all the class locations (either directories or jar files: \jars is just somewhere I am supposing you put your jar files.)

Similar Threads

  1. Basic exception question
    By wulfgarpro in forum New To Java
    Replies: 4
    Last Post: 09-15-2010, 09:49 AM
  2. Basic JSP question..
    By casid in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-28-2009, 06:51 PM
  3. Basic question on OOP.
    By madthinker in forum New To Java
    Replies: 7
    Last Post: 01-26-2009, 07:09 PM
  4. Basic question about EJB
    By javaplus in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-15-2008, 05:44 PM
  5. Very basic question
    By gvi in forum New To Java
    Replies: 2
    Last Post: 10-30-2007, 06:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts