You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by luc <lu...@spaceroots.org> on 2013/01/07 09:46:31 UTC

[math] Re: Help, how to compile? Thanks a huge

Le 2013-01-07 09:29, George Xu a écrit :
> Hi,

Hi George,

>
> Anyone can help? I am new and has difficulty in compiling with the 
> .jar
> files.

First of all, as this list is shared amon several commons components, 
please
set up a marker like [math] in the subject line so we know which 
component you
talk about and to help the numerous subscriber to this list to filter 
your
message appropriately. I have added the marker for you here.

>
> I downloaded the .zip file, unzipped and put the 4 .jar files at
> c:\Users\herehere.
> I wrote a simple test code at the same directory(the current 
> directory, as
> above.
> .(current directory) is at Environmental Variable, CLASSPATH. But it 
> does
> not
> compile simply by .>Javac Test.java.
>
> I compiled with
> .>javac -CLASSPATH c:\Users\herehere\xxx.jar Test.java (I explicitly 
> spell
> out
> xxx and tried all four). The compike passed. But cannot .>java Test, 
> and it
> complains java.lang.NoClassDefFoundError.
>
> Help please,
>
>
> ________________________________
> import
> java.util.*;
> import
> org.apache.commons.math3.*;

The error is in the line above: as Apache Commons Math has several 
subpackages,
using "import org.apache.commons.math3.*;" only imports the class from 
the
first level, the import is not recursive. Also note that using "*" for 
import is
considered bad practice, you should import every class individually.

In your case, you should change this line as follows:

import org.apache.commons.math3.analysis.function.Acosh;

With this change, your program runs and displays the following output:

Hello World!
E @ i:	5
acosh:	1.5667992369724109
E @ i:	1
acosh:	1.5667992369724109
E @ i:	2
acosh:	1.5667992369724109
E @ i:	3
acosh:	1.5667992369724109
E @ i:	4
acosh:	1.5667992369724109


hope this helps,
Luc

> public
> class Test {
> public static void main(String[] args) {
> System.out.println(
> "Hello World!"); // Display the string.
> Vector v=
> new Vector();
> v.add(
> "1");v.add("2");v.add("3");v.add("4");v.add("5");
> v.insertElementAt(v.remove(v.size()-1),0);
> int i=0;
> while(i<v.size()){
> System.out.println(
> "E @ i:\t"+v.get(i));
> i++;
> Acosh a=
> new Acosh();
> System.out.println(
> "acosh:\t"+a.value(2.5));
> }
> }
> }


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org