Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: how to convert this into JNI code

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default how to convert this into JNI code

    Hello i now this is basic and i hope some one helps please read.

    Sample #1
    --> Start
    //this is a java code that calls the JNI to print "Hello World"
    class HelloWorld {
    static {
    //System.loadLibrary("HelloWorld");
    System.load("C:/HelloWorld.dll");
    }
    private native void print();

    public static void main(String[] args) {
    new HelloWorld().print();
    }
    }

    #include <jni.h>
    #include <stdio.h>
    #include "HelloWorld.h"

    JNIEXPORT void JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
    {
    printf("Hello Java Native Interface.\\n");
    return;
    }
    --> End

    And i want to do is that java will get the value of string variables from JNI and it will print hello world. for example in using java like this.

    Sample #2
    --> Start
    public class classOne {
    public static void main(String[]args){
    String stringfrom_classTwo = classTwo.pblic_static_str();
    System.out.println(stringfrom_classTwo);
    }
    }

    // how to convert classTwo into a JNI?
    public class classTwo {
    public static String pblic_static_str(){
    String str = "Hello World";
    return str;
    }
    }
    --> End

    How to convert Sample #2 into JNI code thanks?
    Last edited by Jhovarie; June 11th, 2011 at 10:53 AM.


Similar Threads

  1. Convert DOC,XLS to PDF with Java
    By comm in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: July 2nd, 2013, 04:10 AM
  2. How to convert BCD to ascii
    By slavicp in forum Java Theory & Questions
    Replies: 1
    Last Post: April 5th, 2011, 02:20 PM
  3. Convert C/C++ code to Java
    By cristianll in forum What's Wrong With My Code?
    Replies: 13
    Last Post: November 14th, 2009, 02:43 AM
  4. Convert Java Program to Java ME code
    By rinchan11 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: October 5th, 2009, 10:18 PM
  5. convert GSM to PCM (wav)
    By cilang in forum Java Theory & Questions
    Replies: 4
    Last Post: August 7th, 2009, 03:46 AM