I have a sample java application which I want to trace using lttng-ust JUL. I got the examples from this link to run it locally.
However, there seems to be something wrong. I don't know whether it is with Java package installations or installation of lttng-ust JUL.
I ran the following commads: javac -classpath "$CLASSPATH" Hello.java
and java Hello.java
with CLASSPATH
variable being :/usr/share/java/liblttng-ust-agent.jar
.
The following is the error output:
Exception in thread "main" java.io.IOException: java.lang.UnsatisfiedLinkError: no lttng-ust-jul-jni in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
at org.lttng.ust.agent.jul.LttngLogHandler.<init>(LttngLogHandler.java:74)
at Hello.main(Hello.java:14)
Caused by: java.lang.UnsatisfiedLinkError: no lttng-ust-jul-jni in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2434)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1989)
at org.lttng.ust.agent.jul.LttngLogHandler.<init>(LttngLogHandler.java:72)
at Hello.main(Hello.java:14)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:419)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:192)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
I am working on Photon OS 5 and using OpenJDK17.
I am new to tracing userspace applications and I don't have any idea what might be the problem.
Any suggestions or ideas on what the problem might be?
According to this link and its provided sample, I have to run the java program with the following flag:
-Djava.library.path is the equivalent of LD_LIBRARY_PATH, but for the Java virtual machine (JVM). Here, it points to the directory containing the liblttng-ust-jul-jni.so native library.
In my case, the command would be like this:
java -classpath "$CLASSPATH" -Djava.library.path=/usr/local/lib Hello.java