java.lang.UnsatisfiedLinkError: no gurobijni90 in java.library.path - java

I own an academic license for Gurobi.
I followed the guide, but ended up with a problem.
The steps I went through are:
downloaded the Gurobi .tar.gz
extracted it in the /opt folder with the command tar xvzf gurobi_installer.tar.gz
a folder named "gurobi902" was created in the /opt folder after the extraction
run the command grbgetkey xxxxx xxxxx xxxxxx xxxxxx xxxxx to activate the license
wrote the following lines in the .bashrc and .profile files
export GUROBI_HOME="/opt/gurobi902/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
opened Eclipse and edited the build path of my project and added the external jar of gurobi.jar
When I run the java program in Eclipse I get the message
java.lang.UnsatisfiedLinkError: no gurobijni90 in java.library.path
My system has:
Operating System: Manjaro Linux
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.70.0
Qt Version: 5.15.0
Kernel Version: 4.19.126-1-MANJARO
OS Type: 64-bit
How can I solve it?
Thanks in advance for the help!

I suggest you simplify the problem by testing whether the problem involves the Eclipse configuration, or something more basic. Specifically, your Gurobi installation has an examples/build subdirectory where you can build one of the Java examples provided.
Go to that directory and do make -f Makefile Mip1 and see if that example compiles and runs successfully. If so, then you can focus on the Eclipse setup. If not, you have a simpler example with which to work.

I write what worked for me.
Remove from /opt all the Gurobi installation folders
Reinstall Gurobi with a new license
Set the Path variables correctly, as written in the Gurobi wiki
Relaunch IntelliJ with the default settings (from File -> Launch with default)
(optional) specify again the Path variables in the launch configuration
Run the program
If it still doesn’t work, run:
sudo ln -s /opt/gurobi951/linux64/lib/libgurobi95.so /usr/lib
sudo ln -s /opt/gurobi951/linux64/lib/libGurobiJni95.so /usr/lib
sudo ldconfig

Related

Ant not using my JAVA_HOME to find tools.jar

I realize that this question is going to initially sound like a duplicate of some other questions, but none of the other questions I've looked at fixed my issue.
The short story is that I have a JRE and a JDK installed at different locations. I set JAVA_HOME to point to the JDK, yet ant seems to still search for tools.jar in the JRE location. I'm not sure if this has more to do with my ant installation/configuration, or my JDK installation/configuration.
Here's the long story:
Environment
I am running on Red Hat Enterprise Linux Server release 7.5 (Maipo) on an account that does not have sudo privileges to anything.
My JDK install
The machine already has the JRE installed at /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/jre/bin/java. I am not allowed to modify that install, but I can create my own java installation in a separate location.
The security requirements on my network are very stringent and I am only allowed to put specific pieces of software on the machine. It is possible to ask permission for other pieces of software, but I have to go through an approval process that is a huge pain. I have obtained permission to put JDK 1.8 from openJDK on the machine.
Since openJDK does not release tar balls of the whole installation and since I don't have sudo permissions I attempted to install the JDK by downloading java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64.rpm and java-1.8.0-openjdk-devel-1.8.0.172-13.b11.fc29.x86_64.rpm to /local/apps/openJDK8 and running (from /local/apps/openJDK8)
rpm2cpio < java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64.rpm | cpio -i --make-directories
rpm2cpio < java-1.8.0-openjdk-devel-1.8.0.172-13.b11.fc29.x86_64.rpm | cpio -i --make-directories
For some reason this doesn't seem to do a complete JDK install (I think I must be missing some dependencies). I discovered that libjava.so, libjvm.so, jvm.cfg, and the server folder were missing, so I just created some links to the JRE install that had them (run from local/apps/openJDK8):
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/jvm.cfg usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/jvm.cfg
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/libjava.so usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/libjava.so
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/libjvm.so usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/libjvm.so
ln -s /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/amd64/server usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/lib/amd64/server
That step makes me a little nervous, so it could be part of my problem. At any rate, javac and java seem to work fine.
ANT INSTALL
For my ant installation, I just downloaded a tar ball and extracted it to /local/apps/ant and then did:
export JAVA_HOME=/local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64
export ANT_HOME=/local/apps/ant/apache-ant-1.10.4
I didn't bother updating the path because for now I'm just using fully qualified paths for everything. My ultimate goal is to have Jenkins running all of this anyway and it just uses fully qualified paths.
Results
Now if I try to run ant, I get:
> /local/apps/ant/apache-ant-1.10.4/bin/ant
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/tools.jar
Buildfile: build.xml does not exist!
Build failed
The build.xml does not exist part is of course expected, but the inability to locate tools.jar needs to be resolved. The strangest part for me is that according to the error message, it is actually looking for it in the JRE installation location.
Since ant itself is just a shell script, I modified it to print out a little more information by adding the following lines to the end of the file so that it looks like:
echo Running $ant_exec_command $ant_exec_args
echo JAVA_HOME = $JAVA_HOME
echo JAVACMD = $JAVACMD
echo CLASSPATH = $CLASSPATH
echo LOCALCLASSPATH = $LOCALCLASSPATH
echo ANT_HOME = $ANT_HOME
echo ANT_LIB = $ANT_LIB
eval "$ant_exec_command $ant_exec_args"
Now the output is:
$ /local/apps/ant/apache-ant-1.10.4/bin/ant
JAVA_HOME is /local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64
Running exec "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="$ANT_HOME" -Dant.library.dir="$ANT_LIB" org.apache.tools.ant.launch.Launcher -cp "$CLASSPATH"
JAVA_HOME = /local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64
JAVACMD = /local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/bin/java
CLASSPATH =
LOCALCLASSPATH = /local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar
ANT_HOME = /local/apps/ant/apache-ant-1.10.4
ANT_LIB = /local/apps/ant/apache-ant-1.10.4/lib
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/tools.jar
Buildfile: build.xml does not exist!
Build failed
So JAVA_HOME is clearly set. I can even verify further that ant is actually using the JAVA_HOME value that I set for at least some things because if I remove all of those links I created in my JDK install, it will complain that it can't find libjava.so.
So ant is clearly using my JDK install for at least a little bit, but still looking in the old JRE install for tools.jar.
Any ideas on what is going on?
Figured it out :)
This fix still feels a little more like a workaround than an actual fix, so if someone else has a better solution, I'd be interested to hear it.
I've browsed through the ant source code a bit and discovered that ant has a --launchdiag property which is helpful. Running with that gave me:
/local/apps/openJDK8/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.172-13.b11.fc29.x86_64/bin/java -classpath /local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar -Dant.home=/local/apps/ant/apache-ant-1.10.4 -Dant.library.dir=/local/apps/ant/apache-ant-1.10.4/lib org.apache.tools.ant.launch.Launcher --launchdiag
Launcher JAR= "/local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar"
Launcher JAR directory= "/local/apps/ant/apache-ant-1.10.4/lib"
java.home= "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/jre"
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/lib/tools.jar
tools.jar= "null"
Setting "java.class.path" to "/local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-antlr.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-swing.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-testutil.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-xalan2.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-junitlauncher.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-xz.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-junit.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-log4j.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-javamail.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-bsf.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-resolver.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-oro.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-bcel.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jai.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jsch.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jmf.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-commons-logging.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-launcher.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-jdepend.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-commons-net.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-netrexx.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-junit4.jar:/local/apps/ant/apache-ant-1.10.4/lib/ant-apache-regexp.jar"
Buildfile: build.xml does not exist!
Build failed
In the code I found that that java.home property comes from System.getProperty("java.home") which apparently is not the same thing as JAVA_HOME
By adding -Djava.home=$JAVA_HOME I was able to get it working

Can't set up Maven on Mac OSX

I am new to Mac OSX and I'm running Yosemite. I am trying to set up Maven using this official guide in order to set up a Google Cloud Messaging Backend. Here's what I did:
1) Downloaded Maven zip (version: apache-maven-3.3.9) and Unzipped it
2) As the guide says, I need to add the bin directory to my PATH variable. So I did the following in my terminal
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
The terminal didn't return any response. However when I checked to see if Maven got installed using:
mvn -version
I get a message saying:
-bash: mvn: command not found
What am I doing wrong? Did I follow the steps properly to set up Maven?
EDIT:
MVN Bin Directory path is:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
I tried all the manual steps here and still couldn't get it to work. Then I realized I can easily install it using Homebrew, much more convenient:
brew install maven
that's all you need to install maven for mac!
The $PATH is what point where your programs are, because of that you change it in order to find mvn. Actually you are pointing $PATH to $M2_HOME/bin.
You need to update $M2_HOME to one directory level before mvn bin and before update $PATH.
If this is your mvn home:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
you should use this env vars:
export M2_HOME="/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_60"
export PATH="$JAVA_HOME/bin:$M2_HOME/bin:$PATH"
You can also edit your ~/.profile in order to include these lines, so you don't need to type these exports whenever you open your terminal.
Do
export M2_HOME=/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9

Red Hat Linux Enterprise 5.7 remove Java

I need to uninstall Java jdk1.6.0.27 from RHEL 5.7 and then install another version jre-7u40-linux-x64.rpm.
The firs thing I did was to find out the current java version installed using the
java -version command and the output is "java version "1.6.0_27"".
After that I tried to check the previews version of java with the command:
rpm -qi jdk
The output is "package jdk is not installed"
After installing the package jre-7u40-linux-x64.rpm in the /usr/java directory there are two java packages.
The output of the ls command on /usr/java is:
default jdk1.6.0_27 jre1.7.0_40 jre-7u40-linux-x64.rpm latest.
when I run the command "alternatives --config java" the output is:
*+ 1 /usr/java/latest/bin/java
I am new to RHEL and I need some help to understand the situation.
To conclude I need some help to remove the previews jdk1.6.0.27 and to install jre1.7.0_40.
Thank you in advance for your help!
Best regards,
Claudio
First, find out your real java executable. Start with
which java
This is going to give you some response such as:
/usr/bin/java
Next, do
ls -l /usr/bin/java
(Or whatever it returned).
It will probably write something like:
/usr/bin/java -> /etc/alternatives/java
Do the same for whatever is pointed to by the arrow, until finally, when you do ls -l on it, there is no arrow.
Then, for that particular file, find out which rpm provides it by using
rpm -q -f <full path of the file you found>
It should tell you which package it belongs to, and then you can uninstall that.
However, if the rpm command returns The file ... is not owned by..., then your Java has not been installed using an rpm. It may have been installed manually by someone in the past.
This makes uninstalling it a lot more problematic.
If you haven't found your answer:
leave old java where it is, don't even bother with it
install new version with: rpm -ivh /root/jdk-7u40-linux-x64.rpm
deactivate old java
export new version
Deactivating old java (note entering hashtags before every line, manual installation required editing of profile, so edit it one more):
vi /etc/profile
#JAVA_HOME=/usr/java/jdk1.6.0_27
#export JAVA_HOME
#PATH=$JAVA_HOME/bin:$PATH
#export PATH
Exporting nev version (note adding new lines in profile followed after old entries):
export JAVA_HOME=/usr/java/latest
export JRE_HOME=$JAVA_HOME/jre
export J2RE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$J2RE_HOME/bin:$PATH
Check nev version with standard command for checking of installed sw.
Hope this suits your needs.
Just wondering: you're trying to prepare BFBOX for acceptance? Just courious! If you want more info please send me an email, ok?

Eclipse Error for GLPK library: The dynamic link library for GLPK for Java could not beloaded

I have a java program in which a use the GLPK Solver. The error that i receive when i run it on eclipse is the following:
The dynamic link library for GLPK for Java could not beloaded.
Consider using
java -Djava.library.path=
The current value of system property java.library.path is:
/Users/maria/Documents/solver_library/GLPK/w64
I had the same problem on my old windows computer and i solved it doing the following:
1. Adding in the Java Build Path->Libraries the glpk-java.jar file
2.Adding as the Native library location of the above jar the corresponding path (C:\ProgramFiles\solver_library\GLPK\w64
3. adding in the PATH environment variable the above path.
I am doing exactly the same things on my new MAC OS X computer but still receiving the above error. I did with exactly the same way the steps 1 and 2 above and also I modified through the terminal the PATH system variable. This now is:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/maria/Documents/solver_library/GLPK/w64
Could you please tell me if you have any idea of how to solve this? I am a new Mac user so i don't know many things.
Thanks in advance!
Here's what I did to make it work on OS X.
Install glpk.
I used for this homebrew
$ brew install glpk
$ brew install swig // this package we well need for glpk for java
Install glpk for java http://sourceforge.net/projects/glpk-java/files/glpk-java/
Unzip the archive with:
$tar -xzf glpk-java-1.0.37.tar.gz
$cd glpk-java-1.0.37
Configure with:
$./configure \
CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers \
SWIGFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
Make and install with:
$make
$make check
$make install
Now in swig dir you should have 3 jars:
glpk-java.jar, glpk-java-sources.jar, glpk-java-javadoc.jar and the .lib folder (hidden).
For compiling you need to put glpk-java.jar in your classpath and specify javac option -Djava.library.path=/YOUR_PATH/libglpk-java-1.0.37/swig/.libs

Could not find or load main class org.apache.hadoop.util.VersionInfo

I followed "http://codesfusion.blogspot.com/2013/10/setup-hadoop-2x-220-on-ubuntu.html" to install hadoop on ubuntu. But, upon checking the hadoop version I get the following error:
Error: Could not find or load main class
org.apache.hadoop.util.VersionInfo
Also, when I try: hdfs namenode -format
I get the following error:
Error: Could not find or load main class
org.apache.hadoop.hdfs.server.namenode.NameNode
The java version used is:
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
It is a problem of environmental variables setup. Apparently, I didnt find one which can work until NOW. I was trying on 2.6.4. Here is what we should do
export HADOOP_HOME=/home/centos/HADOOP/hadoop-2.6.4
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
export HADOOP_CONF_DIR=$HADOOP_HOME
export HADOOP_PREFIX=$HADOOP_HOME
export HADOOP_LIBEXEC_DIR=$HADOOP_HOME/libexec
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH
export HADOOP_CONF_DIR=$HADOOP_PREFIX/etc/hadoop
Add these into your .bashrc and dont forget to do
source ~/.bashrc
I think your problem will be solved as was mine.
You probably did not follow the instructions correctly. Here are some things to try and help us / you diagnose this:
In the shell that you ran hadoop version, run export and show us the list of relevant environment variables.
Show us what you put in the /usr/local/hadoop/etc/hadoop/hadoop-env.sh file.
If neither of the above gives you / us any clues, then find and use a text editor to (temporarily) modify the hadoop wrapper shell script. Add the line "set -xv" somewhere near the beginning. Then run hadoop version, and show us what it produces.
Adding this line to ~/.bash_profile worked for me.
export HADOOP_PREFIX=/<where ever you install hadoop>/hadoop
So just:
$ sudo open ~/.bash_profile then add the aforesaid line
$ source ~/.bash_profile
Hope this helps (:
I was facing the same issue. Although it may seem so simple but took away 2 hrs of my time. I tried all the things above but it didn't help.
I just exit the shell i was in and tried again by logging into the system again. Then things worked!
Try to check:
JAVA_HOME, all PATH related variables in Hadoop config
run: . ~/.bashrc (note the dot in front) to make those variables available in your environment. It seems that the guide does not mention this.
I got the same problem with hadoop 2.7.2
after I applied the trick shown I was able to start hdfs but later I discovered that the tar archivie I was using was missing some important pieces. So downloading the 2.7.3 everything worked as it is supposed to work.
My first suggestion is to download again the tar.gz at the same version or major.
If you are continuing to reading... this how I solved the problem...
After a fresh install hadoop was not able to find the jars.
I did this small trick:
I located where the jars are
I did a symbolic link of the folder to
$HADOOP_HOME/share/hadoop/common
ln -s $HADOOP_HOME/share/hadoop/kms/tomcat/webapps/kms/WEB-INF/lib $HADOOP_HOME/share/hadoop/common
for version command you need hadoop-common-2.7.2.jar, this helped me to find where the jars where stored.
After that...
$ bin/hadoop version
Hadoop 2.7.2
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r b165c4fe8a74265c792ce23f546c64604acf0e41
Compiled by jenkins on 2016-01-26T00:08Z
Compiled with protoc 2.5.0
From source with checksum d0fda26633fa762bff87ec759ebe689c
This command was run using /opt/hadoop-2.7.2/share/hadoop/kms/tomcat/webapps/kms/WEB-INF/lib/hadoop-common-2.7.2.jar
Of course any hadoop / hdfs command works now.
I'm again an happy man, I know this is not a polite solution but works at least for me.
I got that error , I fixed that by editing ~/.bashrc
as follow
export HADOOP_HOME=/usr/local/hadoop
export PATH=$HADOOP_HOME/bin:$PATH
then open terminal and write this command
source ~/.bashrc
then check
hadoop version
Here is how it works for Windows 10 Git Bash (mingw64):
export HADOOP_HOME="/PATH-TO/hadoop-3.3.0"
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
export HADOOP_CLASSPATH=$(cygpath -pw $(hadoop classpath)):$HADOOP_CLASSPATH
hadoop version
copied slf4j-api-1.6.1.jar into hadoop-3.3.0\share\hadoop\common
I added the environment variables described above but still didn't work. Setting the HADOOP_CLASSPATH as follows in my ~/.bashrc worked for me:
export HADOOP_CLASSPATH=$(hadoop classpath):$HADOOP_CLASSPATH
I used
export PATH=$HADOOP_HOME/bin:$PATH
Instead of
export PATH=$PATH:$HADOOP_HOME/bin
Then it worked for me!

Categories