Question

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?

Was it helpful?

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.

OTHER TIPS

Download the jar file for ArithmeticUtils from here, and run:

javac -cp commons-math.jar:. MyProgramName.java

What you're saying here is: 'Include all of the classes in the common-math.jar in my compilation, and also any classes in the current directory'.

As a side note - why aren't you using an IDE? It will make your life a lot easier.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top