Strange advise when loading external library with JNA [duplicate] - java

I am trying to run the first example in rootbeer library, which you can find from here.
The issue is, even though I followed all of their instructions, I am getting the following message when I am trying to run the Jar
root#ubuserver3:/home/ubuadmin/JavaJars/HelloWordGPU# java -jar HelloWorldGPU.jar
OpenJDK Client VM warning: You have loaded library /usr/lib/libcuda.so.319.37 which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.NullPointerException
at org.trifort.rootbeer.runtime.Rootbeer.run(Rootbeer.java:104)
at ScalarMult.test(ScalarMult.java:13)
at Main.main(Main.java:17)
I am not a Linux person, so I do not understand how to execute this command properly. I also don't understand what they mean by that message, because this is the first time I am on GPU programming. But I know messing with GPU with wrong commands would be a problem.

Type: execstack --version to check if you already have execstack installed.
If you get command not found type: sudo apt-get install execstack -y --force-yes
Type sudo execstack -c <file>
e.g sudo execstack -c /usr/lib/libcuda.so

1: Check execstack version using following command to find execstack installed or not
execstack --version
2: If execstack not installed then install using following command
sudo apt-get install execstack -y --force-yes
3: After successful installation execute following command
sudo execstack -c <filepath>
eg: sudo execstack -c /usr/lib/libjpcap.so

Make sure you are not running 32-bit Java. If you run java -d64, the 32-bit version will print an error.

make sure you are not running 32-bit jar on 64-bit jvm first

What does the file /usr/lib/libcuda.so.319.37 contain?
If the file is a 0-byte-file, there is something really wrong, so try to repair your system by reinstalling that library.
I had the same problem in smartgit, where a library in the local config folder was used, which was somehow corrupted and was a 0 byte file. So deleting the config folder and restarting the app worked for me. This could be a solution here too.

Related

java.lang.UnsatisfiedLinkError: /usr/local/openjdk-8/jre/lib/amd64/libawt_xawt.so: libXrender.so.1:

I am running my automation test project in Gitlab pipeline. I am getting the exception as "java.lang.UnsatisfiedLinkError: /usr/local/openjdk-8/jre/lib/amd64/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory"
I tried multiple solution for installing and updating the packages but no luck
Tried solutions :
dpkg --add-architecture i386
apt-get update
apt -y install libxext6
apt-get -y install libbz2-1.0:i386 libxrender1:i386 libxtst6:i386 libxi6:i386
apt-get -y install libxrender1 libxtst6 libxi6
could you please suggest?
After running java -jar languagetool.jar I received the same error as your question mentions:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so
Based on this similar question, I tried:
sudo apt-get install -y openjdk-6-jre
Which returned:
Reading package lists... Done Building dependency tree Reading
state information... Done Package openjdk-6-jre is not available, but
is referred to by another package. This may mean that the package is
missing, has been obsoleted, or is only available from another source
However the following packages replace it: icedtea-netx
E: Package 'openjdk-6-jre' has no installation candidate
Hence, I tried:
sudo apt-get install -y icedtea-netx
And that resolved the error.
Are you trying to build the native lib (creating the .so file in the fly) or trying to make use of the pre-built version of it? In the first case, make sure your test-automation tool supports it; in the second case, make sure the presence of your lib file in the appropriate location.
You are probably encountering this error because you do not have the libawt_xawt.so package in your /usr/local/openjdk-8/jre/lib/amd64/ directory.
To fix the problem, follow these steps:
1- Update the package index:
sudo apt-get update
2- Install openjdk-11-jre deb package:
sudo apt-get install openjdk-11-jre
source here.

Javac on Ubuntu

I'm on windows 10 and running the bash shell (ubuntu), by turning the Windows Subsystem for linux on. Anyways, I'm trying to run some Java programs through the command prompt. I have already set the PATH variables and I can successfully run the java and javac commands in the windows command prompt. However, when I run the javac or java command using Ubuntu shell it says those commands are not found? So it lists some options that I can enter and one of those is
sudo apt install openjdk-8-jdk-headless
But when I run this command it says:
E: Unable to locate package openjdk-8-jdk-headless
I don't get it. I already have Java-8 installed and the PATH variables set, it works fine for the windows command prompt but fails to work with ubuntu. What am I doing wrong?
Thanks.
Do you have to use the OpenJDK version? Try this
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
See this link and this issue

Installing and using rJava-dependent libraries on AWS EC2

I am using the machine image available here to host an RStudio server off of EC2 on which I will want to run analysis, in part using xlsx and rvest, both of which require Java and R to cooperate which they do not out of the box. I searched for a few solutions and tried to implement them, but got pretty much nowhere.
I SSH'd into the machine, and entered java -version and got this:
The program 'java' can be found in the following packages:
* default-jre
* gcj-5-jre-headless
* openjdk-8-jre-headless
* gcj-4.8-jre-headless
* gcj-4.9-jre-headless
* openjdk-9-jre-headless
Try: sudo apt install <selected package>
so I'm not sure what to do with that. I tried running sudo apt-get install r-cran-rjava which was also recommend on StackOverflow, and got this error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package r-cran-rjava
and likewise when I try to run sudo R CMD javareconf this is what I get:
*** JAVA_HOME is not a valid path, ignoring
*** Cannot find any Java interpreter
*** Please make sure 'java' is on your PATH or set JAVA_HOME correspondingly
I searched for Java it's stored here: java: /usr/share/java and I'm not sure how to set JAVA_HOME correctly, or how to set Java correctly.
What should I do?
Installing RJava (Ubuntu)
First, we need Java itself, check if it's installed
Write in Terminal: java -version
but you already checked it, so you need to install it.
If it returns The program java can be found in the following packages, then Java hasn't been installed yet, so execute the following command: sudo apt-get install default-jre. This will install the Java Runtime Environment (JRE).
Then Install JDK
Write in Terminal: sudo apt-get install default-jdk
Then assotiate the JDK installed with R
Run in Terminal: sudo R CMD javareconf
Install RJava and Rgdal
Execute: sudo apt-get install r-cran-rjava
Then: sudo apt-get install libgdal1-dev libproj-dev
Install package in RStudio
Run in RStudio: install.packages("rJava")
Done!

Stack guard might have disabled?

I am trying to run the first example in rootbeer library, which you can find from here.
The issue is, even though I followed all of their instructions, I am getting the following message when I am trying to run the Jar
root#ubuserver3:/home/ubuadmin/JavaJars/HelloWordGPU# java -jar HelloWorldGPU.jar
OpenJDK Client VM warning: You have loaded library /usr/lib/libcuda.so.319.37 which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.NullPointerException
at org.trifort.rootbeer.runtime.Rootbeer.run(Rootbeer.java:104)
at ScalarMult.test(ScalarMult.java:13)
at Main.main(Main.java:17)
I am not a Linux person, so I do not understand how to execute this command properly. I also don't understand what they mean by that message, because this is the first time I am on GPU programming. But I know messing with GPU with wrong commands would be a problem.
Type: execstack --version to check if you already have execstack installed.
If you get command not found type: sudo apt-get install execstack -y --force-yes
Type sudo execstack -c <file>
e.g sudo execstack -c /usr/lib/libcuda.so
1: Check execstack version using following command to find execstack installed or not
execstack --version
2: If execstack not installed then install using following command
sudo apt-get install execstack -y --force-yes
3: After successful installation execute following command
sudo execstack -c <filepath>
eg: sudo execstack -c /usr/lib/libjpcap.so
Make sure you are not running 32-bit Java. If you run java -d64, the 32-bit version will print an error.
make sure you are not running 32-bit jar on 64-bit jvm first
What does the file /usr/lib/libcuda.so.319.37 contain?
If the file is a 0-byte-file, there is something really wrong, so try to repair your system by reinstalling that library.
I had the same problem in smartgit, where a library in the local config folder was used, which was somehow corrupted and was a 0 byte file. So deleting the config folder and restarting the app worked for me. This could be a solution here too.

JAVA_HOME environment variable not set Validator.nu HTML Parser

I am trying to install a local version of the Validator.nu server and it keeps failing on trying to build the HTML Parser.
It says it can't find the JAVA_HOME variable which I have set in my .bashrc file and shows correctly when I type "echo $JAVA_HOME" at the prompt
Ideas appreciated thanks
Error output
"hg" pull --update -R build https://bitbucket.org/validator/build/
Not trusting file build/.hg/hgrc from untrusted user dave, group dave
Not trusting file /home/dave/src/checker/build/.hg/hgrc from untrusted user dave, group dave
warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified (check hostfingerprints or web.cacerts config setting)
pulling from https://bitbucket.org/validator/build/
warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified (check hostfingerprints or web.cacerts config setting)
searching for changes
no changes found
Error: The JAVA_HOME environment variable is not set.
Set the JAVA_HOME environment variable to the pathname of the directory where your JDK is installed.
Instead of:
$ sudo python build/build.py all
try:
$ sudo -E python build/build.py all
The sudo command for security reasons resets the environment (so your JAVA_HOME for the python process is wiped out even when it's exported). The "sudo -E" will preserve the environment.
I assume (from tag) you use ubuntu.
list versions of installed javas in your system:
dave#ubuntu:~$ update-java-alternatives --list
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
Note, that if you set JAVA_HOME in ~/.bashrc it will be set only in your terminal sessions.
Unless you export it, it will be set only for your current shell process (not subprocesses like mercurial).
add line to your .bashrc:
export JAVA_HOME="/usr/lib/jvm/java-6-openjdk"
open a new terminal and test it:
$JAVA_HOME/bin/java -version && echo java seen by bash
bash -c '$JAVA_HOME/bin/java -version && echo java seen by bash subprocesses'
If you want to set environment for all processes (not only started by hand from terminal), you can:
dave#ubuntu:~$ sudo $EDITOR /etc/environment
After tackling this for the last 4 days I have managed to get the validator.nu server running on my local Ubuntu VM and so I thought I would update this thread in case anyone else runs in to the same issues.
I am still not 100% sure where the original issue with the JAVA_HOME variable was coming from but I suspect (although I am not an expert at this) that it had something to do with the way I was using sudo to run the python build.
I was initially following the instructions on http://about.validator.nu/#src but using
$ sudo python build/build.py all
This was because part of the build needed the correct permissions to work.
This is my step-by-step process which starts from a clean install of Ubuntu 11.
installed ubuntu 11
opened the terminal
sudo /bin/bash <----------- I THINK THIS IS THE CRUCIAL LINE
apt-get install mercurial
apt-get install subversion
apt-get install openjdk-6-jre
apt-get install openjdk-6-jdk
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
follow rest of http://about.validator.nu/#src instructions
I'm going to need to do it again when I set this up for the internal network for our build scripts so i'll edit this if I've missed out on anything.
Hope this saves another person's headache and lost days!

Categories

Resources