Install commons math library for java in Ubuntu

∥☆過路亽.° 提交于 2019-12-10 21:02:31

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/16909833/install-commons-math-library-for-java-in-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!