0

I need some of the scientific constants for my project and i found jscience lib. but i can't find a way to use jscience constants. I see the TUTORIAL but there was nothing to explain how to use constants.

So how can i use constants in jscience?
And is any more tutorial or samples of use this lib?

max
  • 5,963
  • 12
  • 49
  • 80

1 Answers1

1

You import them :

 import static org.jscience.physics.units.SI.*; // Static import.
 ...
 Unit<Pressure> HECTO_PASCAL = HECTO(PASCAL);
 Unit<Length> KILO_METER = KILO(METER);

Look at the javadoc at http://jscience.org/api/ , you will find many examples.

EDIT:

Actually it's

 import static javax.measure.unit.SI.*; // Static import.

The example in the javadoc is wrong about the package name.

RealHowTo
  • 34,977
  • 11
  • 70
  • 85
  • thanks for your attention but when i import "import static org.jscience.physics.units.SI.*; // Static import." eclipse say "The import org.jscience.physics.units cannot be resolved" (i add jscience to my lib folder) – max May 04 '14 at 14:28
  • You need to add the jscience jar to the build path of your Eclipse project. See http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse – RealHowTo May 04 '14 at 14:43
  • In your project, do you see Referenced Libraries ? Do you see jscience.jar ? Can you see the packages in the referenced jar ? – RealHowTo May 04 '14 at 16:40
  • Well, it should work :-) I see that's an Android project maybe it's related. What happens if you do a plain Java project with a regular JDK ? – RealHowTo May 04 '14 at 18:15
  • Change my example to `javax.measure.unit.SI.*` , the provided example in the javadoc is wrong... – RealHowTo May 04 '14 at 18:27