Search code examples
javaubuntuapache-commons-math

Install commons math library for java in Ubuntu


So I've been looking for a while, and found that I need to import the

org.apache.commons.math3.util.ArithmeticUtils

library in a Java program I'm writing. Now this is my first Java program, and I can't figure out how to use the library.

Am I missing something here? Do I need to attach an option when I'm using the command?

javac MyProgramNameGoesHere.java -something(?)

Or is there some special place where I need to install the the library package to?

Edit::

I am also doing this with gEdit and the bash terminal, not an IDE.

As stated above I am using Ubuntu, so if there is some repository that I can install it from that would be nice to know of, or if I have to manually download it, where do I put it?


Solution

  • To install Apache Commons use:

    sudo apt-get install libcommons-math-java
    

    Set the classpath to whichever directory contains the library you are using. Something like:

    javac -classpath .:/library/directory/path/ MyProgram.java
    

    Run man javac for more information.