Purpose of com.ibm.oti.vm.bootstrap.library.path on AIX j9vm JVM - jvm

Background
I have a C++ program that loads a JVM internally and then uses JNI to call code in the JVM. This runs on multiple platforms including AIX. However, when starting the JVM on AIX everything is fine until I call some code that needs to access native code supplied as part of the JRE. I then run into this error message:
java.lang.UnsatisfiedLinkError: net (Not found in com.ibm.oti.vm.bootstrap.library.path)
The problem is that the JVM cannot find the shared library libnet.so. If I dump the value of the com.ibm.oti.vm.bootstrap.library.path system property from Java code running in the JVM I see that by default (i.e. not me setting it) it has the value:
<jre-base-dir>/lib/ppc/default:<jre-base-dir>/lib/ppc
From the error message I guessed it would be a good idea to change this to include the dir where libnet.so is located. However, this shared library is in <jre-base-dir>/lib/ppc which is already in the path set by com.ibm.oti.vm.bootstrap.library.path, so it seems the error message is incorrect.
Experimenting with different values for this system property makes me believe that it is used by the AIX j9vm to load the internal JVM shared libraries only (like libjclse7b_26.so) but not the native code implementations (like libnet.so).
My fix
To fix my problem I had to change the LIBPATH environment variable (which is AIX the equivalent of LD_LIBRARY_PATH in e.g. Linux).
$ LIBPATH=<jre-base-dir>/lib/ppc:<jre-base-dir>/lib/ppc/j9vm ./myprogram
Questions
Can anyone shed some light on the real purpose of the system property com.ibm.oti.vm.bootstrap.library.path on AIX when using the j9vm JVM?
Is my fix the correct way to solve the problem or should I use some other system property? (I have tried java.library.path but it does not seem to help.)

In my case it show error message:
java.lang.UnsatisfiedLinkError: awt (Not found in com.ibm.oti.vm.bootstrap.library.path)
I fix my problem by
copy /usr/java6_64/jre/lib/ppc64/libawt.so to /usr/java6_64/jre/lib/ppc64/j9vm and create symbolic link libawt.a to libawt.so
I set LD_LIBRARY_PATH
LD_LIBRARY_PATH="/usr/java6_64/jre/lib/ppc64:/usr/java6_64/jre/lib/ppc64/j9vm"; export LD_
LIBRARY_PATH

Related

Is there an updated disk image binary for the x86 architecture for running gem5 in full system mode?

I am currently using the linux-x86.img which I downloaded from the documentation page for gem5 (http://www.m5sim.org/Download), but since I was not able to compile the fscanf and fopen commands on this image I was wondering if there is a more recent image which I could download and use instead.
The error message throw when trying to compile the lines with fopen and fscanf are
./obj/edgelist.o: In function loadEdgeArray': edgelist.c:(.text+0x148): undefined reference to __isoc99_fscanf'
./obj/edgelist.o: In function loadEdgeArrayInfo': edgelist.c:(.text+0x20c): undefined reference to __isoc99_fscanf'
collect2: ld returned 1 exit status
make: *** [test] Error 1
This error is thrown when trying to compile from both from qemu as well as gem5.
Here's one setup that generates such an image with Buildroot. I'm a fan of Buildroot because it builds everything from source. I don't understand how fscanf and fopen could fail in that image, but I have tested them in the above setup and they work fine.
Boot used to work in the past, but gem5 X86 full system boot has been broken for likely easy to fix reasons for a few months now as of March 2020 on the gem5 side, although there are efforts in place to fix it, and so likely it will work again soon: https://www.gem5.org/project/2020/03/09/boot-tests.html
Other alternatives include:
https://gem5art.readthedocs.io/en/latest/ which Jason has been pushing and uses Packer to generate disk images
You can also extract working disk images from Docker: https://hub.docker.com/_/ubuntu This requires exporting them to a file to give to gem5.
It is also worth noting that when the gem5.org website migrated from the old Wiki to the new static website setup in Q1 2020, we lost the ability of doing directory listing under http://dist.gem5.org/dist/current/arm/ for some reason, and so devs were forced to list them one by one on the static website... https://www.gem5.org/documentation/general_docs/fullsystem/guest_binaries
I am not sure why the error is no longer occurring for me, but documenting the steps I went through which might have fixed something. I reinstalled Ubuntu18.04 therefore had to rebuild gem5 and I used the parsec image (http://www.cs.utexas.edu/~parsec_m5/x86root-parsec.img.bz2) referenced in this answer Booting gem5 X86 Ubuntu Full System Simulation

jpype.getDefaultJVMPath() fails when I try accessing JVM from python3

I am currently using Python3, java8, jpype 0.6.3 version on windows10.
jpype.getDefaultJVMPath() fails with an error :
raise JVMNotFoundException("No JVM shared library file ({0}) "
jpype._jvmfinder.JVMNotFoundException: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.
My JAVA_HOME points to C:\Program Files (x86)\Java\jdk1.8.0_241
If I try starting JVM directly by passing the jvm.dll path("C:\Program Files (x86)\Java\jdk1.8.0_241\jre\bin\client\jvm.dll) python program crashes.
I have already given executable permission to .dll file
Could anyone please help me fix this issue for the above system specifications
It is possible that your JVM architecture (32 bit) does not match your Python (64 bit). This would cause the symptoms you are describing.
It turns out that the shared code I was using required a specific version of one of the drivers. I still don't understand it all enough to explain why that was but with the older driver version (from a colleague) everything works!
from jpype import *
startJVM("/home/user_name/Downloads/ideaIC-2022.2.3/idea-IC- 222.4345.14/jbr/lib/server/libjvm.so", "-ea")
java.lang.System.out.println("hello world")
shutdownJVM()
This works for me
set the path manually
startJVM("/home/user_name/Downloads/ideaIC-2022.2.3/idea-IC- 222.4345.14/jbr/lib/server/libjvm.so", "-ea")
If this path is not correct for you
Search for this file libjvm.so inside partition computer on linux
Then copy the file path

XOpenDisplay(NULL) fails to connect to X

I was given a fairly large program to compile and run with extremely vague instructions on how to properly configure my system and install the program. I was told to use a Windows, install Cygwin, navigate to the program's base directory, and type "make". I installed Cygwin on a 64-bit Windows 7 in C:\cygwin64 as the main user (I also installed all of the default packages, plus a few extras) and then ran the makefile included with the program (this worked with no problems). When trying to run the executable with a required file argument, I was simply given the error message "cannot connect to X server." Upon examination of the code, it appears that this error was caused by a line setting display=XOpenDisplay(NULL) and then exiting when this resulted in display == NULL. Earlier, "display" had been declared as a variable of type Display. Is there any way I can get the program to connect to the X server? I have been assured that the installation of the program is extremely easy, but I'm not so sure... Thanks in advance.

JVMTI native agent (DLL) can not be loaded to a runing Java program - AgentLoadException

I struggled on this issue for a few days but didn't get a right answer yet.
Here is the Problem Description:
I wrote a normal Java program (Program-A), and wrote a Windows-based native agent (*.dll, written in C/C++) with Agent_OnLoad, Agent_OnAttach, Agent_OnUnload method, which works fine if using Java command-line flag (-agentlib). Then I wrote another Java program to attach the native agent onto a runing the Java Program-A (see the below code piece for VM attach and loadAgentPath), however I got the exception:
com.sun.tools.attach.AgentLoadException: Failed to load agent library
I tried to change the agentPath (absolute or relative file path) this or that way, none of these works. Should I try some other way to make this work. What I need is to attach a native agent onto a runing java program rather than using command-line flag.
Does anyone know the root cause or a clue for the solution?
BTW, the command line to run attach VM Java code as:
java -Djava.library.path=D:\DevTools\Java7\jre7\bin -classpath .;./tools.jar com.xxx.TestAgentVMAttacher
...
VirtualMachine virtualMachine = com.sun.tools.attach.VirtualMachine.attach(pid); // Note: this code line is executed normally, I am sure the pid is correct
...
agentPath = theFilePath + "/myagent.dll"; // Note: I am sure the dll file path is correct
virtualMachine.loadAgentPath(agentPath,null); // Note: this code line would cause the exception (AgentLoadException) as I mentioned above, no matter how I set the agentPath, even I set it as null, same exception happened.
Environment related info:
- OS: Windows XP
- Java Version: Java(TM) SE Runtime Environment (build 1.7.0-b147)
Eventually I found the answer for my question, I had a wrong method name ('Agent_Attach') in Agent.cpp file, the correct one should be 'Agent_OnAttach', with this fix, my agent lib (.dll) can be loaded to a running Java program now.

Find the commands that jvm was started with during run time (1.6.0_12)

Full story:
I am trying to start up an instance of hudson with a larger memory allocation and I'm currently using scripts owned by root that I can't modify directly to pass arguments. However the script currently passes the $JAVA_ARGS variable when starting up the service. I have exported the required parameters to JAVA_ARGS but the application still appears to be bound by the old memory restrictions.
Question:
Is there a way to find out which command line parameters were used to start up the instance. More specifically I'm looking to find the values that were passed (if any) to Xmx and Xms.
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) 64-Bit Server VM (build 11.2-b01, mixed mode)
After some searching I came about a pretty simple solution (which I'm a little embarrassed to have missed for so long). You can see the command line to any command running in linux with ps, as long as you pass the correct flags. I just made a call to ps -fHu hudson and was able to see the full command line call to java which showed the passed in parameters.
Since you can export $JAVA_ARGS, maybe you can override $PATH to trick the script to run another program instead of the JVM, which could be a program that simply writes its arguments somewhere.