aspose file tools*
The moose likes Java in General and the fly likes Native Method in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Native Method in java" Watch "Native Method in java" New topic
Author

Native Method in java

Prakash Rai
Ranch Hand

Joined: Jan 10, 2011
Posts: 103

1. public final native Class getClass();
2. public native int hashCode();
I have taken these above two method from java.lang package . What is actual use "native"?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

It means that these methods are not implemented in Java itself, but in a platform-specific native library (a DLL if you're running on Windows).

You can use JNI (Java Native Interface) to call non-Java code from a Java program.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Prakash Rai
Ranch Hand

Joined: Jan 10, 2011
Posts: 103

What platform specific native library.?
Jesper de Jong wrote:It means that these methods are not implemented in Java itself, but in a platform-specific native library (a DLL if you're running on Windows).

You can use JNI (Java Native Interface) to call non-Java code from a Java program.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Google for open jdk and you can probably find the source code.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Native Method in java