2

I wanted to access device so i have developed one Java code in eclipse using JNI library which calls c code for communicating with device.

For accessing device we require sudo authentication in eclipse so i have done that authentication using the following link

How do I run my application as superuser from Eclipse?

But right now i am facing the problem in loading JNI libraries in Java code

I am getting error

WARNING: Running as root!
Loading...
Did not load library
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
    at java.lang.Runtime.loadLibrary0(Runtime.java:840)
    at java.lang.System.loadLibrary(System.java:1047)
    at org.sc.ivb.jni.DeviceCommunicationController.<clinit>(DeviceCommunicationController.java:10)
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.sc.ivb.jni.DeviceCommunicationController.Ivb_InitDevice()V
    at org.sc.ivb.jni.DeviceCommunicationController.Ivb_InitDevice(Native Method)
    at org.sc.ivb.jni.DeviceCommunicationController.main(DeviceCommunicationController.java:27)
Community
  • 1
  • 1
rachana
  • 3,344
  • 7
  • 30
  • 49

1 Answers1

4

Don't use sudo for this task! Instead, give the appropriate permissions to the device so that the user can access it. This is possible by either using chmod/chown to change the device file's permissions, or use adduser <username> <group> to add the current user to that devices group.

Tassos Bassoukos
  • 16,017
  • 2
  • 36
  • 40