I have code of a research project managed by datalad (which is a frontend for git and git-annex). It contains my code together with a Singularity container for reproducibility.
I installed java manually into this directory. I could run java -version initially but once I have committed my changes using git annex add <java_dir>, git add . and git commit, I cannot start java anymore. I get the following error message:
Error: could not find libjava.so
Error: Could not find Java SE Runtime Environment.
How can I avoid this incompatibility between java and git-annex?
(Annex: how I installed java)
mkdir lib
cd lib
wget https://javadl.oracle.com/webapps/download/AutoDL?BundleId=246799_424b9da4b48848379167015dcc250d8d -O jre_8_341.tgz
tar -xf ./jre_8_341.tgz # creates jre1.8.0_341/
rm jre_8_341.tgz
cd jre1.8.0_341/bin
Turns out that the java binary tries to find its own path, as can be seen by calling strace java -version:
< ... lots of strace output... >
readlink("/proc/self/exe", "/proj/.git/annex/objects/X5/f3/M"..., 4096) = 120
< ... more strace output ...>
The readlink syscall leads into the .git/annex/objects directory where git-annex saves big files. Thus, java gets the wrong answer what is its installation directory and thus fails.
The solution is to git annex unlock $JAVA_HOME/bin/java (where $JAVA_HOME is the folder you extracted java to). The same must be done with $JAVA_HOME/lib/amd64/server/libjvm.so which tries the same manoever.
Finally, the files must be committed in unlocked state. In effect, the files
must not be symlinks into the git-annex object storage but regular files.
Related
I am using centOS 6.10
ls /usr/lib/jvm
O/P:
java-1.6.0-openjdk-1.6.0.41.X86_64
java-1.7.0-openjdk-1.7.0.181.X86_64
java-1.7.0-openjdk-1.7.0.261.X86_64
java -version
O/P:
java version "1.7.0_181"
while checking for jps I am getting like this,
jps
O/P:
Error: could not find libjava.so
Error: could not find Java SE Runtime Environment.
My bashrc file be like,
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.261.X86_64/
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
I dont know why this error is popping. I am getting frustrated because of this I am searching the solution for more than 3 days. Any help would be much appreciated.
Thanks in advance!!
I found java-related processes are sometimes quirky when it comes to libraries.
First identify the path for libjava.so and confirm the lib and executable are the same, one of 32- or 64-bit:
file /path/to/libjava.so /other/path/to/jps
Next, for any process like jps as an example, run this:
ldd /some/path/jps
The runtime link-editor should list an abs path for each lib referenced by the executable, or an error if not found. When there is an error, the lib is missing or exists in a directory that's not within the link-editor's search path. For normal processes, setting LD_LIBRARY_PATH usually works, but java stuff is too often quirky. Try experimenting with cmd-lines or a script, eg:
#!/bin/bash
LD_LIBRARY_PATH=/usr/local/lib64 /full/path/to/jps $*
(replace /usr/local/lib64 with the leading path to libjava.so).
Note that an independent "export KEY=val" is not required, and would add info into the environ and gets inherited by any process that follows; as shown, the shell sets KEY=val only for the cmd-line.
Some java-related quirks are processes that either clear the environ or reset stuff like LD_LIBRARY_PATH within their own child process(es), or call execve() with a NULL envp, and the child then fails as you describe. In that case you may have to resort to moving libs to a specific dir, or modify a java-related config file which lists lib dirs.
Sometimes quick answers can be found with strace, made easier when limiting the output, eg:
strace -f -e execve,open jps
I am trying to build Casandra project on a Centos server. I downloaded the file from here.
http://apache.bilkent.edu.tr/cassandra/2.0.6/
Here is the README.txt file
This short guide will walk you through getting a basic one node cluster up
and running, and demonstrate some simple reads and writes.
* tar -zxvf apache-cassandra-$VERSION.tar.gz
* cd apache-cassandra-$VERSION
* sudo mkdir -p /var/log/cassandra
* sudo chown -R `whoami` /var/log/cassandra
* sudo mkdir -p /var/lib/cassandra
* sudo chown -R `whoami` /var/lib/cassandra
Note: The sample configuration files in conf/ determine the file-system
locations Cassandra uses for logging and data storage. You are free to
change these to suit your own environment and adjust the path names
used here accordingly.
Now that we're ready, let's start it up!
* bin/cassandra -f
As README.txt file suggested I followed these instructions as adapting to my case (I am not root).
tar -zxvf apache-cassandra-2.0.6-src.tar.gz
cd apache-cassandra-2.0.6-src
mkdir -p var/log/cassandra
chown -R `whoami` var/log/cassandra
mkdir -p var/lib/cassandra
chown -R `whoami` var/lib/cassandra
Since I am not root on the server, I can not create my files under /var folder. So, I created new folder var under apache-cassandra-2.0.6-src and put my lib and log files there. Then I followed next instructions from README.txt file.
bin/cassandra -f
However whatever I tried it is no good, I always get this error.
Error: Could not find or load main class org.apache.cassandra.service.CassandraDaemon
How can I fix this problem?
My java version
java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
EDIT:
As an extra informaiton, I tried this instructions on my pc, too. Exactly same thing with README.txt file using sudo and it worked.
I see you have downloaded the source package (apache-cassandra-2.0.6-src.tar.gz), but the instructions you posted seem to assume it is already built.
You need to build the source package before you can use it; there would be a separate set of instructions for that somewhere.
I suspect you'd rather just run it instead of building it from source. You may have meant to download the binary package apache-cassandra-2.0.6-bin.tar.gz instead (note "bin", not "src" -- this is a traditional naming convention when separating binaries from source in downloadable archives). With that package you can just run it right out of the box. For the source package you'd need to follow the build instructions to compile cassandra first.
I also suspect that you downloaded the binary package on the PC side, which is why it worked there.
If you do need to build from source:
Install ant and ant-optional if you do not already have it.
Extract the source archive somewhere, then in the base directory (where build.xml is):
ant release
Make a cup of coffee (the rat task at the end takes forever).
Binary archives will be created in build, and a built distribution can be found in build/dist.
do a export CASSANDRA_HOME=location of cassandra
should work in 2.0.6 i verified just then without setting that variable and after setting those variables.
$ export CASSANDRA_HOME=/usr/local/cassandra/dsc-cassandra-2.0.6
$ /usr/local/cassandra/dsc-cassandra-2.0.6/bin/cassandra
or
$ cd /usr/local/cassandra/dsc-cassandra-2.0.6
$ export CASSANDRA_HOME=
$ bin/cassandra
in fact you can also set CASSANDRA_HOME= in cassandra-2.0.6 directory. set it to empty value if you are executing the export command from the cassandra directory.
Path for CASSANDRA_HOME was incorrect for me. After i set the correct path it ran perfectly.
In the cassandra.yaml configuration file, change the
commitlog_directory
data_file_directories
saved_caches_directory
properties to the path you have specified as they are no longer /var/lib...
You will need to set them to point to wherever the directories actually are.
I faced exact problem, where I wanted to install cassandra in userspace without any sudo privileges. I did the following
In cassandra.yaml I changed the following config to local path
commitlog_directory
data_file_directories
saved_caches_directory
log4j.appender.R.File
Installed the "bin" tar files for the particular OS env and not the "src" file.
Export CASSANDRA_HOME=/userspace/cassandra-2.x
Now it works fine for me.
I faced same issue when I used Jdk 1.8_281 version.
The problem was resolved when I downgraded to jdk 1.8_241 version.
I'm running Elementary OS (Ubuntu 12 based), and I'm having issues running apache ant. It was working earlier before a restart, so I'm not sure what would've changed.
I've defined environment variables in /etc/environment as follows:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$ANT_HOME/bin"
JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386"
ANT_HOME="/opt/ant"
ANT_OPTS="-Xms256M -Xmx512M"
So my Java and Ant environment variables should be set. I'm trying to deploy with ant, with 'ant clean deploy', but I get an error in my terminal:
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
I've tried "source /etc/environment". Running 'echo $ANT_HOME' shows the correct path. I've tried moving ant to a different location and resetting the variables. Nothing. I'm kind of lost. Please help!
you should define $ANT_HOME before using it in your $PATH
JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386"
ANT_HOME="/opt/ant"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$ANT_HOME/bin"
double check that you have ant-launcher.jar under $ANT_HOME/lib
As others have stated, it looks like ANT_HOME isn't being set before you declare it in your path.
I take a slightly different approach to these things. Instead of constantly updating my PATH, I usually set my path to something fairly simple:
PATH="/usr/local/bin:/bin:/usr/bin/:$HOME/bin"
Then, I make hard links to various binaries into my /usr/local/bin directory.
$ cd $ANT_HOME/bin # All the Ant binaries
> for binary in *
> do
> sudo ln -s $PWD/$binary /usr/local/bin
> done
Now, I don't have to add $ANT_HOME/bin to my $PATH. Even better, if I include /usr/local/bin before /usr/bin and /bin, I am picking the binary in /usr/local/bin first. This way, I can ensure I run the version I installed over the default. For example, my machine comes with Ant 1.7 in /usr/bin/ant but I want to use Ant 1.9.1. I can install Ant 1.9.1, and that will be my default version.
I had same error when install ant with npm install. When I tried install from official repository throw pacman -S apache-ant(apt-get install apache-ant -- for Debian/Ubuntu) it's start working proper for me.
I'm experiencing this bug with jdk 1.8. But, I came across this RHEL 6.5 bug for OpenJDK 1.8 which may be related:
https://bugzilla.redhat.com/show_bug.cgi?id=1149605
Essentially, it's fixed in jpackage-utils-1.7.5-3.13 which is included with RHEL 5.7.
The problem, as Javier Ramirez said in the bug comments:
Your script /usr/share/java-utils/java-functions has problems with
"openjdk version" because it expects "java version" as Java 7 does.
$ mkdir /usr/share/java-1.8.0
$ mkdir /usr/lib/java-1.8.0
$ diff /usr/share/java-utils/java-functions.orig /usr/share/java-utils/java-functions
149,150c149,150
< -e '/java \(full \)*version "/s/'$re'/<<<\1>>>/' \
< -e '/java \(full \)*version "/s/.*<<<\([^>]\{1,\}\)>>>.*/\1/p')
---
> -e '/[java|openjdk] \(full \)*version "/s/'$re'/<<<\1>>>/' \
> -e '/[java|openjdk] \(full \)*version "/s/.*<<<\([^>]\{1,\}\)>>>.*/\1/p')
------
I am using RHEL which comes with ant (in /usr/bin/ant) and the ant libraries in
/usr/share/ant. As suggest above, ant -version gave the "could not find" error.
I installed my own version of ant (in /home/Ant since I have a lot of space
in /home) and put ANT_HOME in my .bash_profile and $ANT_HOME/bin in my PATH
and $ANT_HOME and $ANT_HOME/bin (for good measure) in my CLASSPATH. Then ant
worked (when used as myself, not as root).
I am unable to find clear instructions to install Google Protocol Buffers (including compiler) on Windows x64 platform.
I went through the instructions README file for compiler and source:
For Compiler: To install, simply place this binary somewhere in your PATH
I added system variable to Path:
PROTOC 'C:\dev_tools\protoc-2.4.1-win32'
I am stuck on installing Protocol Buffers source using Cygwin. I tried following
Unix instructions provided in the readme file:
To build and install the C++ Protocol Buffer runtime and the Protocol
Buffer compiler (protoc) execute the following:
$ ./configure
$ make
$ make check
$ make install
If make check fails, you can still install, but it is likely that
some features of this library will not work correctly on your system.
Proceed at your own risk.
make install may require superuser privileges.
For advanced usage information on configure and make, see INSTALL.txt.
** Hint on install location **
By default, the package will be installed to /usr/local. However, on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH. You can add it, but it may be easier to just install to /usr> instead. To do this, invoke configure as follows:
./configure --prefix=/usr
I get
-bash: ./configure: No such file or directory'
Can some one provide clear and detailed steps to make this work?
UPDATE
I switched to using MSYS/MINGW32 instead and
I followed instructions given in this link. Now I am stuck with following:
When I run the './configure' command I get following error:
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check'
As a result, none of the make, make install commands work. For eg:
make: No targets specified and no makefile found. Stop.
If you just want to compile ProtoBuf definitions, you can download precompiled binaries of protoc for all platforms right on the ProtoBuf GitHub releases page.
They had precompiled binaries at least since 2015, but it's easy to overlook them in between the many downloads.
For installing proto buff in windows
Go to https://github.com/protocolbuffers/protobuf/releases
Scroll down and download the zip for windows compatible
Binary File
Once download the zip, extract it to C:/
Just copy the path, C:\protoc-3.17.3-win64\bin and set this as path to an environment variables
path setup
Hope, this helps!
There is a whole documentation file for compiling protobuf on Windows :
https://github.com/google/protobuf/blob/master/src/README.md#c-installation---windows
https://github.com/google/protobuf/blob/master/cmake/README.md
You'll need 7-zip, Cmake and Visual Studio.
Anyway, one of the unexpected side-effects of using a Continuous Integration tool (like Travis or Appveyor) is that there is always a up-to-date and working build script available. I happen to always look at appveyor.yml and travis_config.yml files whenever they exists.
>>> git clone -b v3.1.0 https://github.com/google/protobuf.git
>>> cd protobuf
>>> curl -L -o release-1.7.0.zip https://github.com/google/googlemock/archive/release-1.7.0.zip
>>> 7z x release-1.7.0.zip
>>> del /Q release-1.7.0.zip
>>> rename googlemock-release-1.7.0 gmock
>>> curl -L -o release-1.7.0.zip "https://github.com/google/googletest/archive/release-1.7.0.zip"
>>> 7z x release-1.7.0.zip
>>> del /Q release-1.7.0.zip
>>> rename googletest-release-1.7.0 gtest
>>> move gtest gmock
>>> set generator=Visual Studio 12 Win64
>>> set vcplatform=x64
>>> mkdir build_msvc
>>> cd build_msvc
>>> cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% ../cmake
>>> msbuild protobuf.sln /p:Platform=%vcplatform% || goto error
You'll need curl (Git Bash has it) as well as resolving paths for the 7z.exe and Msbuild.exe executables.
I successfully managed to build the protobuf compiler on a Windows 10 x64 machine with Visual Studio 2015.
Use chocolatey
choco install protoc
Download protoc-2.5.0-win32.zip from
https://github.com/protocolbuffers/protobuf/releases/tag/v2.5.0
Then to install, simply place this binary somewhere in your PATH
I was build protobuf v2.4.1 on Windows 10 as follows:
git clone https://github.com/protocolbuffers/protobuf.git;
cd protobuf;
git checkout v2.4.1;
cd vsprojects
open protobuf.sln in Visual Studio 2019
Press build solution and take many errors: min undefined and max undefined
Add in file protobuf/stubs/common.h next code:
#if defined(_WIN32) && !defined(min)
#define min(a,b) __min(a,b)
#define max(a,b) __max(a,b)
#endif
Press build solution and take error: fatal error C1189: “#error: hash_map is deprecated and will be REMOVED….”
Add compile definition -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS solved problem
Next I had error “error C2664: "std::pair std::make_pair(_Ty1 &&,_Ty2 &&) noexcept”…”
In file src\google\protobuf\compiler\command_line_interface.cc I modified string “proto_path_.push_back(make_pair< string, string >(virtual_path, disk_path));” to “proto_path_.push_back(make_pair(virtual_path, disk_path));”
Press build solution. All build succeed.(Tests projects not build without test framework)
INSTALL:
Run extract_includes.bat to copy all the public headers into a separate "include" directory (under the top-level package directory).
Copy the contents of the include directory to wherever you want to put headers
Copy protoc.exe wherever you put build tools
copy libprotobuf.lib, libprotobuf-lite.lib, and libprotoc.lib wherever you put libraries.
I installed it with chocolatey and it worked perfectly.
choco --install -y protoc
I'd recommend using vcpkg tool on windows. Here is step by step manual.
Regarding protobuf, firstly check what options you have (in cmd):
vcpkg search protobuf
Next install the required package:
vcpkg install protobuf:x64-windows-static
Notice x64-windows-static after the colon - this is the triplet. Check vcpkg help triplet for all of them.
Then go to your_path\vcpkg-master\packages\protobuf_x64-windows-static\
Now you can set your environment variables.
Now protobuf is a NuGet package in Visual Studio. Just go get that.
just easy ref
choco install protoc --pre
choco install protoc --pre worked for, make sure your in an elevated state.
this is the output when I ran protoc from gitbash
$ protoc
Usage: C:\ProgramData\chocolatey\lib\protoc\tools\bin\protoc.exe [OPTION] PROTO_FILES
Parse PROTO_FILES and generate output based on the options given:
-IPATH, --proto_path=PATH Specify the directory in which to search for
adding it to my $path environment variables didn't work from me as expected.
I need to get a stack trace for a JVM process running on a client machine that uses windows.
The client has the JRE installed but not the JDK.
I want to use JStack but it is not installed and we can't install a JDK on the client's machine. I also tried using AdaptJ stack trace product from a Java Webstart Session but that didn't work because we remote in and get an error about not being the session that started the application at a specified PID.
Essentially I want a way to install JStack without installing the JDK.
You probably want to use SendSignal, which was designed for exactly this purpose.
The JDK and associated tools work fine whether "installed" or not, if you just zip up and extract it to a temporary directory, you should be able to run jstack. (No PATH or JAVA_HOME modifications necessary). Just make sure you use the same version that corresponds to the JRE your client has the application running with. At least in the case of JConsole, it seems to fuss if the versions are different. I'm not sure if jstack behaves the same way.
I'm not saying this is the ideal solution, just that it would work. I think jdigital and Eddie's suggestions are better first bets, and even though this shouldn't interfere with an existing java installation the same way running the installer would, the customer may disagree regardless.
jstack and jps are part of tools.jar of the JDK.
Also attach.dll is required to attach jstack to a process.
Ofcourse the tools.jar and attach.dll are not part of JRE.
To make jstack work on a systems which has no JDK (mostly Windows), I usually do the following.
Copy tools.jar and attach.dll from JDK and put in to some location
on the target system. Example: to c:\temp\jstack
Write a bat script to manually invoke it using JRE.
For example, create a bat file jstack.bat:
set JRE=c:\jrefolder
"%JRE%\bin\java" -classpath "c:\temp\jstack\tools.jar" -Djava.library.path="c:\temp\jstack" sun.tools.jstack.JStack %*
Similarly for jps, create a jps.bat with following content.
set JRE=c:\jrefolder
"%JRE%\bin\java" -classpath "c:\temp\jstack\tools.jar" -Djava.library.path="c:\temp\jstack" sun.tools.jps.Jps %*
Usage:
jstack.bat -l <pid>
Hope this helps.
Would you be able to use JConsole via remote access?
To get a thread dump with only a JRE you need tools.jar and attach.dll from the JDK of the same Java version. Install this somewhere and copy these into the jre. Must be identical version!
If you need a dump of a process running under the system account you can use the Windows sysinternals psexec.exe to gain access to the process. Copy this into the JRE bin or somewhere in the path.
This batch file writes the stack dump to a file with a datetime filename so multiple traces can be taken and compared easily.
Threads.bat
:: Creates a thread dump for the tomcat6.exe process
:: saved in a timestamped filename and views it!
:: Jim Birch 20111128 rev 2015-10-12
::Required the following files to be placed in the jre/bin folder:
:: attach.dll - From the Java JDK (must be the same version)
:: tools.jar - ditto
:: psexec.exe - from Windows sysinternals
::cd to jre/bin
d:
cd \application\jre\bin
::build datetime filename
rem datetime from wmi.exe
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set dt0=%%I
rem datetime string as YYYY-MM-DD-hhmmss
set dt=%dt0:~0,4%-%dt0:~4,2%-%dt0:~6,2%-%dt0:~8,6%
set ff=td-%dt%.txt
echo filename: %ff%
::PID of the process by named exe, eg, tomcat6
for /F "tokens=2" %%I in ('TASKLIST /NH /FI "IMAGENAME eq tomcat6.exe"' ) DO SET PID=%%I
echo pid: %PID%
::combine above with jstack command
psexec -s jstack.exe -l %PID% >> %ff%
:: view result
start %ff%
::insert pause to debug or timer to review script operation
::ping localhost -n 20 >nul
::pause
If you want to use the on-board tools of the JDK and also want to both have a minimal (i.e., not including copying the whole JDK) and convenient (i.e. not invoking with a custom .bat) solution, this works for me (tried on Java 1.8):
Create an empty folder ($DEST below) and copy the following files (from the JDK $JDK_HOME) into bin and lib folders as follows:
Source -> Destination
$JDK_HOME/bin/jps.exe -> $DEST/bin/jps.exe
$JDK_HOME/bin/jstack.exe -> $DEST/bin/jstack.exe
$JDK_HOME/bin/jli.dll -> $DEST/bin/jli.dll
$JDK_HOME/jre/bin/attach.dll -> $DEST/bin/attach.dll
$JDK_HOME/lib/tools.jar -> $DEST/lib/tools.jar
Then ZIP and copy this over to the destination machine running a compatible JRE.
You should be able to run jps and jstack from the bin folder now as you would run them from the original JDK.