Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1037351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:50:33+00:00 2026-05-16T14:50:33+00:00

I am using the Java Native Interface to include some statically compiled code in

  • 0

I am using the Java Native Interface to include some statically compiled code in with my Java application. Particularly, I’ve got a DLL file with the compiled code in the WAR that contains my application.

Unfortunately, the class loader can’t load the DLL from inside the WAR (from preliminary research… if this is wrong, be sure to tell me!). So I have to copy the DLL out to a temporary folder, and then load it from there.

But when I then try and load the copied DLL, I get java.lang.UnsatisfiedLinkError: C:\path\to\dll\VIX.dll: %1 is not a valid Win32 application. The file sizes look the same (both 401K, according to Windows), but it just doesn’t work. Here’s the code that does the copying:

InputStream ReadDLL = Thread.currentThread().getContextClassLoader().getResourceAsStream("/VIX.dll");

File file = new File(workDir, "VIX.dll");
OutputStream WriteDLL = null;
try {
    WriteDLL = new FileOutputStream(file);
} catch (FileNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}

byte[] buffer = new byte[1024];
int numchars;
try {
    while((numchars = ReadDLL.read(buffer)) > 0) {
        WriteDLL.write(buffer, 0, numchars);
    }
    ReadDLL.close();
    WriteDLL.close();
} catch (IOException e) {
    e.printStackTrace();
}

Comparing the original and the copied versions of the DLL, I find that every instance of the byte 0x0A (The ASCII linefeed character) in the original is being replaced with two bytes: 0x0D0A (An ASCII CRLF). Of course, this being a DLL, the 0x0A is not actually a linefeed, just a binary opcode. But for some reason, Java insists on doing this helpful translation for me.

Finally, the ReadDLL InputStream is being obtained by calling Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); where, obviously, fileName is the name of my file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:50:33+00:00Added an answer on May 16, 2026 at 2:50 pm

    Two hypotheses:

    1. Maybe the DLL was modified by an UNIX-to-Windows FTP transfer using default ASCII mode (use the bin mode for FTP transfer).
    2. Maybe the DLL was treated as an ASCII file in a revision control system and was checked out on a Windows system.

    Try to unzip the WAR and see if it’s the original or modified version.

    I don’t see any case where Java or the webapp server would perform that conversion in your back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java application which interacts with native code using JNI. The native
I'm using a native c++ dll out of an Java application with the JNA
I'm in the process of doing some Java<->.NET interop code using a native library
I've been trying to code a simple screenshot application using rococoa (java to osx
In a Java project, I am using a third-party library that loads some native
When using the java native interface on android I made two silly mistakes that
I am trying to create header file for java native method in android application
Edited Question: Trying to use a .dll file from Java using JNA. I've managed
I am using Java native serialization along with a dynamic proxy to save the
What is the best procedure for storing and retrieving, using native Java serialization, generic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.