• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

native methods

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why calling a native method like this result in a runtime error?

Maybe we have to load a library?
Then why in the StrictMath class there's code like this?

the class's comment states that all the algorithm gives the same
result as certain published algorithms.



/**These
* algorithms are available from the well-known network library
* <code>netlib</code> as the package "Freely Distributable
* Math Library" (<code>fdlibm</code>
* The network library may be found on the World Wide Web at:
* <blockquote><pre>
* <a href="http://metalab.unc.edu/">http://metalab.unc.edu/</a>;
* </pre></blockquote>
* <p>
**/


When this Library is loaded if no code there declares something
like this?
[ February 17, 2003: Message edited by: Igor Zeta ]
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it a runtime error or a compile time error?
Does your code compile?
The first line needs a semicolon.
 
Igor Zeta
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
provided the semicolon this is
the resulting run-time error:


java.lang.UnsatisfiedLinkError: amethod
at provecocoon.NewSuper.amethod(Native Method)
at provecocoon.NewSuper.main(NewSuper.java:25)
Exception in thread "main"

 
Dan Culache
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I didn't read carefully. I thought you were trying to use a native method defined in the StrictMath class. I'm not familiar with the Java linkage process but I'm sure this is what you need to do, specify a library. I believe your method "amethod" should be part of a library which was built using the Java Native Interface.
see Java Native Interface
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic