I am new to JAVA Programming & JNI. How to call getpid() C library function in Java program using JNI? I went through following post How can a Java program get its own process ID? but unable to run program. Thanks in advance
I have written following program
public class ProcessId
{
public static void main(String[] args) {
CLibrary clib = (CLibrary) Native.loadLibrary("c",Library.class);
clib.getpid();
System.out.println("Process Id is "+getpid());
}
}
I am getting following errors
1)Library cannot be resolved to a type
3)The method getpid() is undefined for the type ProcessId
Above mentioned post talk about platform.jar file. I downloaded one from http://grepcode.com/snapshot/repo1.maven.org/maven2/net.java.dev.jna/platform/3.4.0 and included in Project Libraries. But it still not worked out..