Jump to content
Excelsior Forums
Freddy

Building Plain JAVA SE appl. which uses JNA to load .dll library.

Recommended Posts

I'm new to this (JNA and .dll), so having some problems.

My JAVA SE program is quite simple, but uses JNA to load one third party .dll library.

.dll file location is in the working directory.

Command line:

java -cp "<paths_to_all_jars>" my.package.Main

When running from CMD (in JVM obviously) the JNA finds and loads the .dll from working directory without any errors.

When performing a test run in JET, JNA throws an exception that it's unable to load the library and module could not be found.

When the test run is ending, JET wants me to create a new project with command like this:

java -cp "<paths_to_all_jars>" com.sun.jna.Native$DeleteNativeLibrary C:\Users\Freddy\AppData\Local\Temp\jna2338540727581562715.dll

Not sure why and what it does.

Could you guide me what I'm doing wrong and how to solve this?

Thank you.

Share this post


Link to post
Share on other sites

Hello,

We need to clarify some details about your problem.

It would be easier to continue our discussion if you duplicate your message to <java@excelsior-usa.com>.

--

Excelsior Support

Share this post


Link to post
Share on other sites

If anyone would ever needs this:

I was trying to load 64bit dll as I was using 64bit JRE.

However JET version I'm using is 32bit and it just needed 32bit dll which works fine.

-----------------------------------------------------

Regarding the "New project" after test run.

From the email:

>> When the test run is ending, JET wants me to create a new project with command like this:

>> java -cp "<paths_to_all_jars>" com.sun.jna.Native$DeleteNativeLibrary C:\Users\Freddy\AppData\Local\Temp\jna2338540727581562715.dll

It looks like your program tries to create new "java.exe" process, am I right? Generally it is a bad idea to create new Java process because "java.exe" is not a part of Java Platform and may be implemented in various ways in various JVMs. It is a good idea to directly call required methods or do it using reflection.

However I'm not creating a new "java.exe" process. Maybe some code in JNA does.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×