This problem has arisen while working with the Java Chromium Embedded Framework (JCEF).
The JCEF uses a native SO library (libcef.so) and a SO library for the JNI bindings (libjcef.so). I believe the embedded Chromium looks for a file named icudtl.dat next to it, i.e. in the same directory that the libraries reside.
For the following explanation, asume that all those required files are in the same directory, named jcef_libs.
I wrote a test application using JCEF. After compiling, if I execute it with the java command, i.e.
$ export LD_LIBRARY_PATH=/path/to/jcef_libs
$ java -cp src/main/java:/path/to/maven/repo/jcef.jar:/path/to/maven/repo/jogl-all/2.2.4/*:/path/to/maven/repo/gluegen-rt/2.2.4/* tests.simple.MainFrame
it works flawlessly.
On the other hand, using the exec-maven-plugin raises a fatal error, due to not finding the named icudtl.dat file. The POM file is configured to use exactly the same artifacts as the java command does.
$ mvn exec:java -Dexec.mainClass="tests.simple.MainFrame"
[1201/123038:FATAL:content_main_runner.cc(721)] Check failed: base::i18n::InitializeICU().
I have tested the java command with the icudtl.dat file removed from the jcef_libs directory, experiencing the same error, i.e. the error raises only when the icudtl.dat is not found.
Any help will be appreciated.
UPDATE
I have been tracing what maven does under the hood. The failing mvn command above executes this internally:
java -classpath /usr/share/maven2/boot/classworlds.jar -Dclassworlds.conf=/usr/share/maven2/bin/m2.conf -Dmaven.home=/usr/share/maven2 org.codehaus.classworlds.Launcher "exec:java" "-Dexec.mainClass=tests.simple.MainFrame"
I.e. it executes my test application through a launcher. I don't know where this launcher is going to execute my application but, again, I need the icudtl.dat in that directory.
Any idea how could I workaround this?
Related
I am trying to run the spark application which is written in java in GKP. For the same I am able to build the image and placed in the container. But while running the spark application with spark-submit command I am facing an error which is
Error: Could not find or load main class org.apache.spark.launcher.Main
The java and spark versions i am using for this was jdk-11 and spark-3.2.1
I am running this application via IntelliJ with maven. Also tried adding the spark-launcher maven dependency still the issue exists.
Can I know where it is going wrong with this versions.
NOTE : I can see the spark-launcher jar in the spark-3.2.1 jar folder as well.
I had that error message. It probably may have several root causes but this how I investigated and solved the problem (on linux):
instead of launching spark-submit, try using bash -x spark-submit to
see which line fails.
do that process several times ( since spark-submit calls nested
scripts ) until you find the underlying process called : in my case
something like :
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -cp
'/opt/spark-2.2.0-bin-hadoop2.7/conf/:/opt/spark-2.2.0-bin-hadoop2.7/jars/*'
-Xmx1g org.apache.spark.deploy.SparkSubmit --class org.apache.spark.repl.Main --name 'Spark shell' spark-shell
So, spark-submit launches a java process and can't find the org.apache.spark.launcher.Main class using the files in /opt/spark-2.2.0-bin-hadoop2.7/jars/* (see the -cp option above). I did an ls in this jars folder and counted 4 files instead of the whole spark distrib (~200 files). It was probably a problem during the installation process. So I reinstalled spark, checked the jar folder and it worked like a charm.
So, you should:
check the java command (cp option)
check your jars folder ( does it contain ths at least all the
spark-*.jar
?)
Hope it helps.
I am having some issues running tensorflow with java. I am using CUDA 8 with CuDNN 6.
I tried following the quickstart instructions located here: https://www.tensorflow.org/install/install_java and get the following error message when I attempt to run the example java program:
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot find TensorFlow native library for OS: linux, architecture: x86_64. See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java/README.md for possible solutions (such as building the library from source). Additional information on attempts to find the native library can be obtained by adding org.tensorflow.NativeLibrary.DEBUG=1 to the system properties of the JVM.
at org.tensorflow.NativeLibrary.load(NativeLibrary.java:75)
at org.tensorflow.TensorFlow.init(TensorFlow.java:66)
at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:70)
at org.tensorflow.Graph.<clinit>(Graph.java:258)
at HelloTF.main(HelloTF.java:8)
The jni directory contains the following:
libtensorflow_framework.so
libtensorflow_jni.so
LICENSE
I then tried installing the binaries from source as suggested here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/README.md
This is the output from setting: org.tensorflow.NativeLibrary.DEBUG=1
org.tensorflow.NativeLibrary: tryLoadLibraryFailed: /path/to/jni/libtensorflow_jni.so: libcublas.so.8.0: cannot open shared object file: No such file or directory
org.tensorflow.NativeLibrary: jniResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_jni.so
org.tensorflow.NativeLibrary: frameworkResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_framework.so
But I still get the same error message when I try and run the example Java program.
What am I doing wrong??
Any help would be greatly appreciated!
The error
Cannot find TensorFlow native library for OS: linux, architecture: x86_64.
is clearly stating that the library is not visible to your software.
To make it available to the Java class, try doing like that (in the same shell obviously):
export LD_LIBRARY_PATH=/the/absolute/path/to/your/library
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
also ensure you're running the java command from the same directory which contains the /jni directory.
For those landing here and facing the same issue.
You are probably trying to run your program from eclipse. Then, you have to go to Run configurations > Arguments and pass this arguments:
Program arguments -> models/
images/example-400x288.jpg
VM Arguments -> -Djava.library.path=./jni
like in this screenshot:
When people (like myself) come from python to java world, everything is strange! here is how I solved my problem regarding all linking errors:
I assumed you already have simple hello Tensorflow project, explained here
Download and copy tensorflow JNI files to :/usr/lib/tensorflow
Download and copy desired version of tensorflow Lib jar file to: /usr/lib/tensorflow
Compile with java
Compile java file
javac -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar HelloTensorFlow.java
run java file:
java -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar:. -Djava.library.path=/usr/lib/tensorflow/ HelloTensorFlow
use MAVEN
First we should export LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/tensorflow
Then run maven build command:
mvn -q compile exec:java
I hope it helps you
I'm developing an Java application using Netbeans and Maven. I'm struggling a lot to run the project as standalone application. Launching the project from Netbeans is all fine but running the executable jar yields an error (failing to load a data file).
I need to know exactly which command(s) Netbeans is executing to run the application. However, the output window of Netbeans only shows me what the application writes "back". Is there a way to figure out/display the command(s) that Netbeans is using to run the project?
Thanks
EDIT: Running the java application and loading files is not the issue here. I'm able to run the application and the libraries are loading correctly. The issue here is to understand how Netbans runs the application (by looking at the commands that are executed).
Netbeans outputs the command it invokes as the very first line of the output.
I use Netbeans 8.2 and that's how it looks like when I hit big green Run button in maven project:
The first line reads (formatted for better readablility):
cd D:\test;
"JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_112"
"M2_HOME=C:\\Program Files\\apache-maven-3.3.3"
cmd /c "\"\"C:\\Program Files\\apache-maven-3.3.3\\bin\\mvn.cmd\"
-Dexec.args=\"-classpath %classpath com.test.AppStarter\"
-Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_112\\bin\\java.exe\"
-Dexec.workingdir=D:\\test\\target\\dist
-Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\"
-Dfile.encoding=UTF-8
org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
From that line I can tell that Netbeans:
goes to the project's directory
sets environment variables (JAVA_HOME and M2_HOME)
then executes cmd that executes mvn (by its full path)
with bunch of -D arguments (which specify working directory and AppStarter as a class to execute)
and exec-maven- plugin with target exec.
When NetBeans compiles a program it creates a folder-hierarchy with compiled .class files. When creating a JAR archive ZIPs those into the archive. When executing the program, (or debugging,) NetBeans runs the .class files off the folders, not in the JAR file.
These could cause different problems, like different PATH. This can cause "file not found" errors with relative paths.
what is your operatingsystem?
windows:
then wmic may be the tool, which could show you the complete commandline. you will find examples here command line of process by name
linux:
try
ps -ef | grep java
I have a bioinformatics related tool can be found here. The tool can be download from the link under that page.
It is a Java packaged files for which on Windows I can run
a compiled version (see the readme, need to change name of Mold2.doc to Mold2.exe) using the following command line:
Mold2 -i TestCompounds.sdf
(I have moved the TestCompounds.sdf file to same path as that exe)
It will produce some message and output 2 files output.txt and report.txt.
The trouble is that this package doesn't have any pre-compiled version executable for Mac OS.
However, since Java is supposedly cross-platform and since I also have the java Mold2.jar file, I think it would work for me if I can execute under Mac OS. But I can find the way how to do that...
I have tried with:
java -cp Mold2.jar Mold2
But it only invoke the GUI, and I can't find how to execute this program with only arguments under terminal without invoking the GUI, which is what I want is for integration purpose.
So how can I run this tool on Mac OS on terminal?
Here's what I did:
Downloaded Apache ZooKeeper 3.4.6 (.tar file), extracted to C:\cygwin\home\user\zookeeper-3.4.6\
Ran ant at the root of the ZooKeeper folder (C:\cygwin\home\user\zookeeper-3.4.6)
Navigated to C:\cygwin\home\user\zookeeper-3.4.6\contrib\ZooInspector\
Ran ant, and I get the following error:
Output:
Buildfile: C:\cygwin\home\Jean\zookeeper-3.4.6\contrib\ZooInspector\build.xml
BUILD FAILED
C:\cygwin\home\user\zookeeper-3.4.6\contrib\ZooInspector\build.xml:19: Cannot find C:\cygwin\home\user\zookeeper-3.4.6\contrib\build-contrib.xml imported from C:\cygwin\home\user\zookeeper-3.4.6\contrib\ZooInspector\build.xml
Total time: 0 seconds
This leaves me with no .cmd or .sh file to execute. How come the build-contrib.xml file isn't there?
Also, I noticed that there seems to be an already-compiled ZooInspector JAR file: zookeeper-3.4.6-ZooInspector.jar. However, attempting to run it with the following command yields failure too:
$ java -cp zookeeper-3.4.6-ZooInspector.jar:lib/* org.apache.zookeeper.inspector.ZooInspector
Error: Could not find or load main class org.apache.zookeeper.inspector.ZooInspector
This is a bit frustrating -- setting up the ZooKeeper server was straightforward but for some reason I just can't figure out how to run this standalone GUI. What am I missing?
For windows:
#echo off
set cp="./*;./lib/*;../../*;../../lib/*"
java -cp %cp% org.apache.zookeeper.inspector.ZooInspector
ZooInspector 3.4.6 (that's bundled with ZooKeeper 3.4.6) doesn't seem to be able to connect to a running ZooKeeper instance on Windows.
Better use zkui:
https://github.com/echoma/zkui/wiki/Download
zooInspector just need 3 libraries and 1 jar to load the main class.
the mainclass lives zookeeper-3.3.0-ZooInspector.jar and it needs jtoaster-1.0.4.jar, zookeeper-3.3.0.jar and finally log4j-1.2.15.jar
After download the tar.gz file from apache servers, you must untar and build with ant. finally copy the zookeeper-3.3.0.jar and log4j-1.2.15.jar to contrib/ZooInspector/lib/. Finally cd to contrib/ZooInspector and launch this command
java -jar zookeeper-3.3.0-ZooInspector.jar -cp lib/*
I met the same issue today, and created a pre-compiled version, which should work on Windows as well. You can find details here:
https://www.admon.org/scripts/zooinspector-zookeeper-graphic-interface/