JNI - Error File Not Found!!!
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: JNI - Error File Not Found!!!

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Trivandrum, Kerala, India
    Posts
    2

    JNI - Error File Not Found!!!

    Hi

    I've a java application which calls DLL created in Managed C++.
    I could successfully make a call to C++ Method. But when I try calling a class (which resides in a different DLL) inside the same method (in c++), it gives error "System.IO.FileNotFoundException: Could not load file or assembly...."

    This is what I've done.
    1. Created a Java application which calls the C++ function.
    2. Created the header file using javah
    3. Implemented the method in the C++ DLL.
    4. In the same method tried to instantiate a C++ Class (gives error at runtime).

    **************
    System.IO.FileNotFoundException: Could not load file or assembly 'Util, Version=2.0.3.4, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
    File name: 'Util, Version=2.0.3.4, Culture=neutral, PublicKeyToken=null'
    at <Removed for posting in public forum>.Execute(String[] args)
    at Java_Test_Execute(JNIEnv_* je, _jobject* jo, _jobjectArray* joa) in <Removed for posting in public forum>.cpp:line 40

    === Pre-bind state information ===
    LOG: User = <Removed for posting in public forum>
    LOG: DisplayName = Util, Version=2.0.3.4, Culture=neutral, PublicKeyToken=null
    (Fully-specified)
    LOG: Appbase = file:///C:/Program Files (x86)/Java/jdk1.5.0_14/bin/
    LOG: Initial PrivatePath = <Removed for posting in public forum>
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: No application configuration file found.
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Java/jdk1.5.0_14/bin/Util.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Java/jdk1.5.0_14/bin/Util/Util.DLL.
    LOG: Attempting download of new URL file:///<Removed for posting in public forum>/3d3fce08/java.exe/Util.DLL.
    LOG: Attempting download of new URL file:///<Removed for posting in public forum>/3d3fce08/java.exe/Util/Util.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Java/jdk1.5.0_14/bin/Util.EXE.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Java/jdk1.5.0_14/bin/Util/Util.EXE.
    LOG: Attempting download of new URL file:///<Removed for posting in public forum>/3d3fce08/java.exe/Util.EXE.
    LOG: Attempting download of new URL file:///<Removed for posting in public forum>/3d3fce08/java.exe/Util/Util.EXE.


    **************

    If I copy all the dlls to "C:/Program Files (x86)/Java/jdk1.5.0_14/bin", it works without any error.

    I tried the following
    1. Setting the folder name using "AppendPrivatePath"
    2. Setting the folder name using "SetDynamicBase"

    Still .Net does not seem to find the dll file.

    How to fix it? I don't want to copy the application to Java/Bin folder

    Thanks and Regards,
    Unni

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: JNI - Error File Not Found!!!

    This is not an area I have much experience in (and the little experience I have had is from years ago) so the following is more suggestion than advice.

    I guess it works when you put the dll's in C:/Program Files (x86)/Java/jdk1.5.0_14/bin because that path is set in the environment variable PATH. If this is the case you should be able to solve your problem by setting java.library.path system property to include the directory the DLL's normally reside in.

    You can set this programmatically using System.setProperty(..) or on the command line by passing the following switch to java ie
    Code:
    java -Djava.library.path=c:\myApp\myNativeDlls myApp
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Jul 2004
    Posts
    8

    Re: JNI - Error File Not Found!!!

    You can System.out.println(System.getProperty("java.library.path")) to see what paths have been added.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center