You are here : Home » knowledge exchange
Make a java file which native method
public class NativeDemo {int i;public static void main(String args[]) {NativeDemo ob = new NativeDemo();ob.i = 10;System.out.println("This is ob.i before the native method:" +ob.i);ob.test(); // call a native methodSystem.out.println("This is ob.i after the native method:" +ob.i);}// declare native methodpublic native void test() ;// load DLL that contains static methodstatic {System.loadLibrary("NativeDemo");}} javah -jni NativeDemo Make file NativeDemo.c
Implement native method here
Compile it using Microsoft C/C++ compilerCl /LD NativeDemo.c Error:LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartupNativeDemo.exe : fatal error LNK1120: 1 unresolved externalsEvery C/C++ program needs a "main" function, either written by you orprovided implicitly by some library. I guess you need to write one.


Copyright © 2005-2012 Narola Infotech, Custom Software & Website Development Company | All Rights Reserved.