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

Has anyone used JMagick? I imported the jar using maven and got error "java.lang.UnsatisfiedLinkError: no JMagick in java.library.path". After lot of research, I found that I should set the path of libJMagick.so file in java.library.path. http://www.jmagick.org/6.4.0/ only has the sourcecode of jmagick. I tried following the instructions here (https://gist.github.com/kei2100/4688805) to build jmagick. I'm stuck at below line
./configure --with-java-home=/System/Library/Frameworks/JavaVM.framework/Versions/Current --with-magick-home=/usr/local/Cellar/imagemagick/6.7.1-1/
It keeps failing with error "configure: error: 'Unable to locate jni.h'" I have jni.h under my java_home/include folder. I tried passing include folder using --with-java-includes argument. But it still keeps failing. Any idea how to move forward?

As stated here, you have to specify the JDK include paths as compiler flag, e.g.:
./configure CPPFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux" --with-java-home=$JAVA_HOME --with-magick-home=/usr/local/Cellar/imagemagick/6.7.1-1/
Alternatively you can also create a file named config.site and specify the compiler flags there (as stated here).

Related

Java can't find native library path

I know this is a quite common question but I think I tried every solution without success.
The error I get:
Native code library failed to load.
java.lang.UnsatisfiedLinkError: no App_JavaAPI in java.library.path
I've appended the path to the directory of the App_JavaAPI.dll on PATH variable on Eclipse. I've tried to add the path to the file itself and even adding both on the PATH env variable defined at OS level.
Moreover, I've tried to put the line:
-Djava.library.path="path to the dir or to the dll itself"
with no success as well. In this case, if I put the path to the dll itself the error is still there. Otherwise, if I put only the path to the dir, I get the error:
java.lang.UnsatisfiedLinkError: path_to_the_dir\App_JavaAPI.dll: The network path was not found
Do you have any other advice?
Thanks all,
Andrea

How to fix "NoClassDefFoundError" with BCrypt (org.mindrot.BCrypt)?

I try to create a Minecraft Plugin (it's my first one) and I can't fix this error:
So, the plugin compiles good but when the code has to execute this code :
BCrypt.checkpw(mdp, result.getString("mdp"))
that come from the lib org.mindrot.BCrypt, I have this error :
Caused by: java.lang.NoClassDefFoundError: org/mindrot/BCrypt
But, when I open my JAR with WinRAR, there is my lib bcrypt (so it's well export). And it's also in my .classpath.
Can you help me ?
Thanks.
There are several ways to configure the CLASSPATH when launching a java application via the java command. According to what you posted so far, I would use the -classpath flag:
java -classpath spigot.jar;jbcrypt.jar class.containing.main.method.MyMain
Alternatively, you could modify the MANIFEST in file spigot.jar. Refer to Adding Classes to the JAR File's Classpath.
Or you could copy jbcrypt.jar to the directory pointed to by the java System property "java.ext.dirs".

JSP compilation fails when using dynamic classpath generated by IntelliJ IDEA on Windows

I have a Spring/MVC/Tomcat website project that I am attempting to run with IntelliJ IDEA. Because I am running on Windows, there is a command-line size limit, which is exceeded by the large classpath. I use IntelliJ's dynamic classpath feature which puts the classpath in a jar file to shorten the command line. Java runs with -classpath <classpath.jar>.
When I try to view a page, the JSP compilation fails with an error to this effect:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [-1] in the generated java file: [<removed>.java]
[javac] <removed>.java:11: error: package javax.servlet does not exist
[javac] import javax.servlet.*;
[javac] ^
I ran it in debug and stepped into where the java compilation was being done and found the javac command line used. It was put together in org.apache.tools.ant.taskdefs.compilers.JavacExternal. I ran the javac command myself, with -verbose, and noticed that the dependency path from the search path for class files: log line shows up like:
C:\Users\<removed>\AppData\Local\Temp\file:\C:\Users\<removed>\lib\servlet-api-3.0.jar
Note that it seems like the absolute URI path is being treated as a relative path, resulting in an invalid path. I believe this is why it's not compiling properly.
Intellij's generated pathing jar's MANIFEST.MF lists the classpath with entries that are absolute paths that look like:
file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/charsets.jar file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/deploy.jar [...]
This problem doesn't happen on Mac, using dynamic classpath jar (even though it's not necessary because the command line too long error does not happen) so I believe something about the Windows path or the way that IntelliJ generates the classpath jar on Windows is messing up the JSP compilation.
Also, using an Ant build task that generates a pathing jar with relative paths works too, but I am interested in avoiding the use of Ant here.
How can I get this working, or what else do I need to investigate to get to the root cause?
This is a known bug in JDK.
Javac incorrectly handles absolute paths in manifest classpath headers. It has been fixed in JDK9.
When I investigated this problem, assuming Java8, I found a different root cause in my case.
In short:
The "/org/apache/jasper/servlet/TldScanner.java" on Line 102, attempts to scan locations for potential JARs.
It uses the "/org/apache/tomcat/util/scan/StandardJarScanner.java" to actually search.
Put a breakpoint on Line 221 URL[] urls = ((URLClassLoader) classLoader).getURLs();
You will see this ClassLoader has the "classpath.jar" as a potential JAR to scan (i.e. process).
But it cannot further find JARs referenced by a (classpath.jar) JAR's manifest file. Meaning, the real JAR(s) you need are not going to be checked.
A short fix, a for this is to:
Add "standard-1.1.2.jar" to your web/WEB-INF/lib/ dir.
If you look inside this jar, you will see *.tld files.
Test:
You can put a breakpoint on TldScanner.java Line 311 found = true;.
When it is not working, you will never hit this line.
When it works, with this (or any) fix, it will hit this line.

JPL/SWI Prolog configuration failure

I'm configuring the JPL right now, and wanna work with swi-prolog using java.
I downloaded the newest stable version of SWI-Prolog, which is 6.2.0, and installed in D:\swipl
First, I added the following path to the PATH virable: D:\swipl\bin, which should include all dll files needed.
Then, I added the following path to the CLASSPATH virable: D:swipl\lib\jpl.jar, which should be the jar file needed.
When I tried to run the versions example provided, I got the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I
at jpl.fli.Prolog.thread_self(Native Method)
at jpl.Query.open(Query.java:286)
at jpl.Util.textToTerm(Util.java:162)
at jpl.Query.Query1(Query.java:183)
at jpl.Query.<init>(Query.java:176)
at Versions.main(Versions.java:11)
After searching online, I found that many people just get java.lang.UnsatisfiedLinkError: no jpl in java.library.path which is because of the setting for the PATH variable, rather than the error I get here: java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I (and yes, there is a "I" at the end of the line).
Has anyone gotten this error before? I've tried several previous version of SWI-Prolog, but also got other kinds of errors. I'm using Eclipse IDE for Java development -- have I missed anything?
I've sent the problem to the official mailing list (swi-prolog#lists.iai.uni-bonn.de) provided by swi-prolog.org, and luckily someone helped me to prove that there are some problems in the version 6.2.0. We then both tried the version 6.0.2, and it works perfectly. He mentioned that (and I noticed that) there is no swipl.dll in the bin folder of the version 6.2.0, which MAY causes the issue.
I've already reported the issue to the staff via Email, and at least for now, I suggest that people who want to configure JPL should download the version 6.0.2. Three things to remember:
add a new variable SWI_HOME_DIR under system variables in environment variables, and set the path to the place where you installed the SWI-Prolog (Mine is D:\swipl);
Add the path %SWI_HOME_DIR%\bin to your PATH variable, rather than use something like "D:\swipl\bin". (Otherwise [FATAL ERROR: Could not find system resources] will occur)
Add the path %SWI_HOME_DIR%\lib\jpl.jar to your PATH variable, rather than use something like "D:\swipl\lib\jpl.jar". (Otherwise [FATAL ERROR: Could not find system resources] will occur)
If you are using Eclipse for Java development, it seems that you DO NOT need to configure in your IDE. As long as you follow the 3 steps above and add the correct jar file as an external library, it should be fine.
I'm not sure whether the temporary solution works for everyone, but definitely, everyone who has the issue should try this method first. As long as the issue in the version 6.2.0 has been figured out, I'll add some comments here.
BTW, as far as I know, until now, people who have the issue are using 32-bit Windows.
Try adding your path to java.library.path via Run > Run Configuration > [project name] and add the following under "VM Arguments" tab.
-Djava.library.path="D:\swipl\bin;."
Furthermore, under the "Environment" tab, add the following:
VARIABLE: PATH
VALUE: D:\swipl\bin;${env_var:PATH}
After that, go to Project > Properties > Java Build Path, select "Libraries" tab.
Click "Add External JARS.." and find your jpl.jar.
Great Great Great, second answer is the solution
create SWI_HOME_DIR variable to set the swi prolog instalation directory
SWI_HOME_DIR ------- C:\Program Files\swipl
set PATH to point to the library and bin like this
PATH ------ %SWI_HOME_DIR%\bin;%SWI_HOME_DIR%\lib\jpl.jar
This fix my problem "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path windows" it is a little bit rare but it works find.
I had the same problem. In addition to set the PATH, you need to verify if the installed SWI program has the same architecture (32 or 64) of your JVM.

how to overcome this exception

i am using a third part SDK with my java application.The providers of sdk provided me exe file that i installed and one java project.I installed the exefile.
Now when i run the code i get a dialog box showing error
Excepting a absulut path for library AKSSDK.dll
No AKSSDK in java.library.path
could not load load library AKSSDK
how do i resolve it?
You need to run java with the following configuration:
java -Djava.library.path={where your library is}
Note the above is the directory where your library is, not the full path name of the library!
You have to add AKSSDK.dll to your PATH environment variable.
It would look like this:
echo %PATH%
C:\xyz\;C:\other\etc\etc;C:\Your\Path\To\AKSSDK.dll
EDIT
To modify your environment variable you have to go to:
MyComputer/RightClick/Properties/Advanced/EnvironmentVariables
(source: vlaurie.com)
And modify the existing Path under System variables
See this tutorial for more details: http://vlaurie.com/computers2/Articles/environment.htm
I have had problems with the white space of ( Program files ) in the past. If possible install your SDK on something like C:\SondaSDK or C:\You\SondaSDK
That way you shouldn't have problems.
You can manually set the path to this value by starting with
java -Djava.library.path=PATH_TO_LIBRARY

Categories

Resources