I have a project which is using some native libraries (.dll). I'm using Netbeans, and I've specified java.library.path in the run configuration. Running the project from Netbeans yields no errors.
I'm using Maven, and when building the project my jar is built in the target
folder. I'm copying all the .dlls and my program's dependencies to target/lib
with maven resources and dependency plugins.
When I try to run my application "outside" of Netbeans, I get the following error:
Can't load this .dll (machine code=0xbd) on a AMD 64-bit platform
This is the command I use to run the .jar:
java -Djava.library.path=lib\ -jar abcontrol-1.0-SNAPSHOT.jar
This is the command (I think) Netbeans uses to run the project from the IDE:
cd C:\Users\Birger\Workspace\myproject; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_77" cmd /c "\"\"C:\\Program Files\\NetBeans 8.1\\java\\maven\\bin\\mvn.bat\" -Dexec.args=\"-Djava.library.path=lib\\ -classpath %classpath com.mysite.myproject.Main\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_77\\bin\\java.exe\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.1\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
I was thinking maybe the java
command uses a different java version than Netbeans, so I tried:
"C:\Program Files\Java\jdk1.8.0_77\bin\java.exe" -Djava.library.path=lib\ -jar abcontrol-1.0-SNAPSHOT.jar
But still, I get the same error.
How can I run my application without Netbeans?
EDIT
From the answer provided to this question: How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?, I added
System.out.println(System.getProperty("sun.arch.data.model"));
To my code to try to get the JVM architecture printed. I ran the application from Netbeans and "outside" netbeans, and in both cases it printed 64
.
EDIT2
Running java -version
prints
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
EDIT3
I tried to create another project using the same dependencies and libraries. This time I did NOT use maven, and in this project I get the same errors when I try to run the project:
Can't load this .dll (machine code=0xbd) on a AMD 64-bit platform
Clearly, maven is doing some magic to get this project to run.
EDIT4 (getting deseprate)
Tried running these two commands
"C:\Program Files\Java\jdk1.8.0_91\jre\bin\java.exe" -d32 -Djava.library.path=lib\ -jar abcontrol-1.0-SNAPSHOT.jar
"C:\Program Files\Java\jdk1.8.0_91\bin\java.exe" -d32 -Djava.library.path=lib\ -jar abcontrol-1.0-SNAPSHOT.jar
Both yields
Error: This Java instance does not support a 32-bit JVM. Please install the desired version.