I am able to load a DLL library on my machine by putting it in a directory found in the PATH environment variable. I can also specify System.setProperty("jna.library.path","C:\\dev"); and that works. For some reason I cannot get it to work on another box that's running the same version of JBoss.
I tried dropping the DLL in C:\WINDOWS which is in the system PATH variable as well as a few other places and nothing works. Also, I tried putting it in C:\eclipse_dev\jboss-4.2.3.GA\bin which is in the user PATH variable.
The only differences between these machines are that mine is Win XP and the other that's not working is Windows server 2003 and also there are multiple users for windows server 2003, but I still have administrator privileges.
How is it failing? It could be missing dependent libraries. Try opening the DLL in the Dependency Walker tool. This will tell you whether there are dependent DLLs that can't be found on the system. If the DLL was compiled with Visual Studio, a likely culprit is that the Windows Server 2003 machine is missing the Visual C++ runtime DLLs which must be installed with the redistributable runtime package.
Related
I have an Owasp Zap program that was working fine on java8, Windows 10. Recently, I upgraded to Java 11 as our automation project will not run on anything else. I have removed Java 8 folders from my C: drive and edited the environment variables and everything works fine except for Zap, which gives the error:
This application requires a Java Runtime Environment 1.8.0. The registry refers to a nonexistent Java Runtime Environment installation or the runtime is corrupted.
I went to my registry but under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\ there was only references to the 11.0.5 jdk
I don't have anything in my environment variables pointing to the old jre as far as I can verify.
I don't have java 8 in Control Panel\All Control Panel Items\Programs and Features, although maybe when I deleted it, I deleted manually and should have ran a cleanup program.
Following some advice here, I looked for a jvm.dll file in Runtime Lib in my registry, but I don't even see a Runtime Lib. I also don't see any of the other java related folders other people mentioned finding in their registries that fixed this problem for them. This is what my registry looks like:
Also I noticed in Control Panel > Programs, there is a link for Java referring to the Java Control Panel, but it is a blank file icon, and when I click it, i get the message "Application not found"
Unfortunately, IT took my admin rights so I can't uninstall and reinstall Zap, but I'd love to solve this this weekend if it's possible.
I have uninstalled the old runtime and download the offline installation from https://www.java.com/en/download/manual.jsp. After installing the offline installation it's working fine for me.
OS is Linux Ubuntu 16.04 LTS
(The application runs absolutely fine on Windows, I did not have to configure anything after the installation of Matlab Compiler SDK)
I am writing a web application in Java which also calls some functions written in Matlab which requires install Matlab Compiler SDK, after the installation, it told me to append this /usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64: to the end of the LD_LIBRARY_PATH variable, which I did by
export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64:
But why do I keep getting this error when I try to run the web app in Netbeans?
java.lang.UnsatisfiedLinkError: Failed to find the required library libmwmclmcrrt.so.9.0.1 on java.library.path.
This library is typically installed along with MATLAB or the MCR. Its absence may indicate an issue with that installation or the current path configuration.
libmwmclmcrrt.so.9.0.1 resides inside the /usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64 directory
I also added -Djava.library.path to point to 3 directory entries above to see if it helps, but it does not do anything good at all.
I read several posts on here, but did not seem to solve it.
JNI: Library is Found on Path, but Method is not (java.lang.UnsatisfiedLinkError)
java.lang.UnsatisfiedLinkError even on setting -Djava.library.path
How do I fix this? BTW, this is a web application
[ Tested on Mac OS High Sierra version 10.13.5 (17F77), should be similar for Linux ]
What I did was when I started the application server (In my case Payara). I provided the path to the javabuilder.jar like so
For Payara Full
asadmin deploy --libraries /path/to/javabuilder.jar app.war
For Payara Micro
java -jar payara-micro.jar --deploy app.war --addlibs /path/to/javabuilder.jar
Note:
/path/to/javabuilder.jar is the location of javabuilder.jar within the directory MATLAB_HOME/MATLAB_Runtime/SOME_VERSION/toolbox/javabuilder/jar/javabuilder.jar, Copying this javabuilder.jar file out and reference it will fail with the same error. It must be its original path for it to work. Not sure why
I'm really tired of computers not having the necessary Java version I need, or I don't have admin privileges to install it. I've seen tons of windows tutorials, but I'm on a Mac. So can someone tell me how to put Java 7/8 on a flash drive, and how to create a script to run a jar file with the version on my drive I have selected? Thanks! I'm on Mac OS X 10.10
Based on your comment to another answer
I have a computer I can do it on with admin privileges
It sounds like you just want to have the JVM/JDK on some portable media that you can run from after you plug it into another computer. This should be simple assuming you only plan on using it on comparable systems. For example, you won't reliably (or at all) be able to install Mac x64 java binaries on a flash drive and try to run it on a Windows machine.
So assuming you only intend to run it on comparable machines, it's as simple as copying the directory structure from the root of the Java install directory. On my Mac OsX 10.9.5 it's /Library/Java/Home. Once you have it on the drive, you just plug it into another Mac. It should automount and you open up a terminal to the root of that mount. cd into the $JAVACOPY/bin (where $JAVACOPY is the directory structure you copied) and you can run ./java -version to verify you are running it.
If all is well after doing that, you can launch any JAR file from that flash drive mount directory with
cd /Volumes/flashMount/Java/Home/;
./bin/java -jar /Users/myuserid/myJar.jar
Keep in mind that Java doesn't strictly require any of the formal install process that systems like Mac and Windows surround it with. All of the fluff involved with "installing" java is about setting up the system to use whichever Java version is installed without the user having to know or care. But you can have as many versions of java as you want in the file system without "installing" them and they should all function just fine (ignoring classpath collisions for certain libraries.)
so I have this project in java that uses a jni .dll i wrote (which i've aptly named jniusb) that gives access to usb-hid devices. i've been using it for several months now without any notable issues until yesterday when i tried to launch my program from the jar instead of directly from netbeans. after a little debugging i characterized my issue as follows:
clicking on the jar icon starts my program without loading the dll. displaying the error messages in my gui revealed "no jniusb in java.library.path" even though i copied my dll to the java binaries folder (which always seemed to work in the past).
i tweaked the code to find the current directory and use "System.load" (with the dll copied to the same folder as my jar) instead of "System.loadLibrary". this approach threw the error "C:\Users\bpaik\Documents\NetBeansProjects\JniUsb\dist\jniusb.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform". this made me scratch my head since i am most definitely working on an AMD 64-bit platform and running out of netbeans works with the same dll...
running the jar from the command prompt (with either java.exe or javaw.exe) loads the dll just fine. i thought that maybe this meant that i was having admin privileges issues so i tested the theory by going to the java executable and granting admin privileges, but this did not change anything. (and i'm also pretty sure i've used load/loadlibrary before without admin...)
i am no java expert so i've pretty much exhausted my debugging abilities and am now hoping that someone with a little more experience than i will recognize the issue i've described, thanks.
UPDATE: so i've fixed the problem but I still have no idea what is going on. i did a x86 build of my .dll and threw it into the folder with my jar and everything loaded/worked just fine. so i guess somehow (even though i set the default program for my jar to be the x64 JVM) the jar i built with the x64 library in Netbeans is running in a 32-bit JVM. to sum things up:
my jar is built with the x64 library in netbeans and runs fine with the x64 dll when launched from the command prompt.
when launching the jar from the icon (with default program set to x64 java) my program and JVM somehow switch to a 32-bit JVM and work fine when i use the 32-bit version of my dll.
trying to explicitly run my jar with the 32-bit java doesn't work at all. my gui doesn't display and the command prompt briefly opens/closes...
Problem 2 is certainly caused by you running a 32-bit JVM. Netbeans presumably runs a 64-bit JVM. You'll need to use something like Launch4j to get the right JVM loaded (or include both a 32-bit and 64-bit version of your DLL).
From the command line, try -d32 and -d64 to test that theory out.
Do you have multiple versions of Java installed on your Machine? It appears that when you run the jar by itself, your machine is creating a 32-bit VM for it. Open an command prompt and type java -version to check which version of Java is being used.
We've got a GWT web app that uses JNI to call a dll. We build the dll as well. It works fine on my developer machine, which is a 64-bit Windows 7 machine, running Java 6 and running the webapps in Tomcat 6. But when we run it on the tester's VM which is running 32-bit WinXP, it errors with
java.lang.UnsatisfiedLinkError: Cannot load native JNIWrapper library (jniwrap64.dll)
at com.jniwrapper.Library.loadNativeCode(SourceFile:78)
at com.jniwrapper.Library.loadNativeCode(SourceFile:103)
at com.jniwrapper.Library.ensureNativeCode(SourceFile:113)
at com.jniwrapper.Library.load(SourceFile:189)
My JRE_HOME is set to a 32-bit version of Java 6, because I wanted the build to be able to work on a 32-bit machine, but clearly I'm mis-understanding something about how the 32 or 64-bit versions of java work in compiling the web app.
And yes, the dll that we call is built in to the .war, since it works on my machine.
I also googled the jniwrap64.dll but didn't find much that was relevant.
Added for clarification : jniwrap64.dll is not the dll that I've built, and my code is not explicitly loading this library. That's part of my confusion, is what is this library, why is it being loaded, etc. I have assumed that jniwrap64.dll is some kind of system library that needs to be installed. My code that loads our library is as follows:
Library myLib = Library(path);
myLib.load(this.getClass().getClassLoader());
When you load the dll with System.loadLibrary() do you load "jniwrap64.dll" or "jniwrap32.dll" ? Cna you show us the line of code which loads this library?