I am trying to accessing dll methods in java which has been written in c#. From the following code i am trying to build dll which is generated successfully.
using System;
using Microsoft.Win32;
namespace CyberoamWinHelper
{
public class RegistryAccess
{
public static String getValue(String key)
{
RegistryKey rk = Registry.CurrentUser;
RegistryKey rk1=rk.OpenSubKey("Software\\Test", RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl);
rk1.SetValue(key, "val1");
return rk1.GetValue(key).ToString();
}
public static void createSubkey(String name)
{
RegistryKey rk = Registry.CurrentUser;
rk.CreateSubKey("Software\\Test");
}
}
}
After this i am loading the generated dll in my java program code of which is as follows
public class JNI {
/**
* @param args the command line arguments
*/
public native String getValue(String key);
public static void main(String[] args) {
// TODO code application logic here
try
{
System.loadLibrary("CyberoamWinHelper");
JNI j=new JNI();
System.out.println(j.getValue("abc"));
}
catch(UnsatisfiedLinkError e)
{
System.out.println("Ex" + e.getMessage());
}
}
}
After running this code it is giving me the following error.
"Exjni.JNI.getValue(Ljava/lang/String;)Ljava/lang/String;"
Well i am not understanding what this error is saying but i want to solve it. And one more question i am having is since the method i am calling is a static method will it be called in this way? i mean to call static method we need
"classname.methodname"
so here will it be able to call the method?