I've followed the following article http://seanchenxi.com/java/sass-compass-jruby-single-jar/ on how to get a jar with ruby, sass and compass.
I'd like to use this as part of a Jenkins plugin. Is there a way to call this programatically from Java the same way that you would run from the command line java -jar jcompass.jar -S compass compile --help?
Warbler can do that ... try packaging up with the runnable feature and see how it goes :
java -jar jcompass.jar -S compass compile
... even if it does not work please report with the project - should be "easily" fixable
Related
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
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?
I'd like to implement python syntax checking in a Java application without and external dependency of the python executable.
I downloaded the Jython standalone jar and I'm looking for a behavior similar to Python's -m py_compile option.
Have you tried it? Works fine here.
# java -jar jython-standalone-2.7.0.jar -m py_compile run.py && echo 'good'
good
I have just downloaded Leiningen but I cannot manage to run it. After downloading its own Jar archive, the script fails with a java error. By running bash -x lein I can see that it hangs at this line:
+ exec java -Xbootclasspath/a:/home/andrea/.m2/repository/org/clojure/clojure/1.2.1/clojure-1.2.1.jar -client -Dleiningen.original.pwd=/home/andrea/bin -cp /home/andrea/.clojure/clojure.jar:::::test/:src/:resources/:/home/andrea/.lein/self-installs/leiningen-1.6.2-standalone.jar clojure.main -e '(use '\''leiningen.core)(-main)' /dev/null
Which produces:
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Compiler.eval(Compiler.java:6476)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
Interestingly, what fails is not the Java call, but the snippet '(use '\''leiningen.core)(-main)'. Running that line without it fires in fact a working clojure REPL. The leiningen-1.6.2-standalone.jar seem to be in the right path. Any ideas? I am new to both Java and Clojure...
According the the reference [1], you need to add Clojure home to the classpath.
echo "export CLOJURE_HOME=$HOME/Opt/clojure
export CLASSPATH=$CLASSPATH:$CLOJURE_HOME" >> $HOME/.profile
[1] http://myminutes.wordpress.com/2011/12/01/clojure-lein-gives-error-exception-in-thread-main-java-lang-runtimeexception-java-lang-nosuchmethoderror-clojure-lang-keywordlookupsite/
Chui Tey's answer points in the right direction. If, however, you don't have a stand-alone Clojure installation, but instead solely use Leiningen to bootstrap your projects, you should instead add the Leiningen standalone JAR to the classpath.
Thus:
export CLASSPATH="$CLASSPATH:$HOME/.lein/self-installs/leiningen-VERSION-standalone.jar"
Is there a way to pass the output of git describe --tag to my Java application at compile time? I'd like to use that in my about box to display version info. I'm using Eclipse to build, but I can use ant if necessary.
With C code, I can pass -D'REV="$(shell git describe --tag)"' to my gcc compiler, and my code can pick that up. I'm hoping there's something similar in Java.
If ant is acceptable, it supports a similar command line option.
As a concrete example, this line in an ant script
<echo>property: ${property}</echo>
when invoked with the following command,
$ ant -Dproperty="$(git --version)"
produces the following output on the console,
[echo] property: git version 1.7.5.4