Results 1 to 6 of 6

Thread: Native methods of java

  1. #1
    Join Date
    Dec 2009
    Posts
    59

    Native methods of java

    Hi ALL,

    I am beginner in the Java programming. Java concepts seems to be very complicated for me than other programming language. I not getting the 'Native methods' of the java programming. Even I don't its declaration. I wonder if you are able provide me some information about the native methods of java programming. Your any help over this would be greatly appreciated.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Native methods of java

    The 'Native method' of java is a amazing way for to merger as well as to gain the power of C++ and C language within Java. Native methods are used for Java as a scientific and high performance language. In case of efficient native Java compilers aren't fully implemented, use native method can boost the performance to at least the speed of C compiled code. The declarations for native methods are almost identical to the declarations for regular, non-native Java methods.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Native methods of java

    Hi friend,

    Refer following java example which depicts the declaration of the 'Native methods' in java programming:
    public class JMPI1
    {
    public native int Init(String arg[];

    public native int Finalize();

    static
    {
    System.loadLibrary("JMPI1");
    }
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Native methods of java

    Hi,

    The native methods of java language must be implemented using native language,for example C++. Before implementation of the native methods it is very important for to generate the header file which comprises the function prototype of the implementation of native method. The native method function definition in the implementation code must match the generated function prototype in the header file.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Native methods of java

    Hello friends,

    A native method is a Java language methods and which implementation is written in other programming language like C++. The Java language only provides a mechanism for integrating C code into Java programs; thus the lessons on this trail focus on writing native methods in C. First you need to write a native method declaration for each native method by specifying it with the native keyword.

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Native methods of java

    Hi,

    Below I have given one java example to demonstrate the Native methods of java. This java program is very easy to understand the use of Java Native methods. Here 'printText ()' is a native method :
    Code:
    class JnativeDemo
        
    {
        public native void printText ();// Native method declaration
    
       {
    
       System.loadLibrary ("JnativeDemo"); 
    
       }
    
        public static void main (String args[])
    
       {
    
       JnativeDemo JnativeDemo= new JnativeDemo ();
       
        JnativeDemo.printText ();
    
       }
    }

Similar Threads

  1. Identify active methods in java
    By Maya Angelou in forum Software Development
    Replies: 4
    Last Post: 06-04-2010, 01:53 PM
  2. C++ as native code in java
    By Miles Runner in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 12:31 AM
  3. What is Export Methods in Java?
    By NIcaBoy in forum Software Development
    Replies: 4
    Last Post: 13-02-2010, 06:29 AM
  4. join() and isAlive() methods of java
    By Owen Fernandes in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 08:28 AM
  5. Methods in JAVA
    By Caiden in forum Software Development
    Replies: 3
    Last Post: 18-08-2009, 11:26 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,641,915.35040 seconds with 16 queries