participate


Java Native Interface (JNI) - Impossible to use VS2005 with Java?
<<   Back to Forum  |   Give us Feedback
This topic has 12 replies on 1 page.
cowwoc
Posts:383
Registered: 7/12/00
Impossible to use VS2005 with Java?   
Mar 3, 2006 1:11 AM

 
If I run java.exe to start up a program using JNI and I use LoadLibrary() to load up any VS2005 DLL such as msvcrt80d.dll then I get error r6034 complaining about how it is illegal to load DLLs directly. VS2005 seems to expect that I link against a manifest file. Since java.exe was not compiled against any manifest file this makes it impossible to load DLLs.

Is there any workaround?
Gili
 
andrew_malcolm
Posts:2,140
Registered: 11/12/01
Re: Impossible to use VS2005 with Java?   
Mar 3, 2006 12:41 PM (reply 1 of 12)  (In reply to original post )

 
You can't load just any native library using loadLibrary

loadLibrary() is designed to load JNI libraries. If you want to access code in a native library such as the one you mention, you must write a native library (see the JNI tutorial) to act as a bridge between java and the native library
 
cowwoc
Posts:383
Registered: 7/12/00
Re: Impossible to use VS2005 with Java?   
Mar 3, 2006 2:31 PM (reply 2 of 12)  (In reply to #1 )

 
Ok, so I think Webstart is broken. Webstart won't unpack a DLL unload you loadLibrary() on it, and if you can't loadLibrary() a non-JNI DLL it makes it impossible to distribute VS2005-built applications which need to unpack MSVCRT80.DLL, its associated manifest files, etc.

Is there an explicit way to tell Webstart to unpack these resources?
 
JaimeMartin
Posts:2
Registered: 4/14/06
Re: Impossible to use VS2005 with Java?   
Apr 14, 2006 5:05 PM (reply 3 of 12)  (In reply to original post )

 
Same problem , and my solution was to create a manifest file for java.exe. The process is very simple, create a c++ project using this libs, then build in vs2005, by default it will generate a manifest file with the name myProjectName.exe.intermediate.manifest and with this typical contents:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>

Then copy this file to same folder as java.exe , and rename it to java.exe.manifest and SOLVED! :)
 
cowwoc
Posts:383
Registered: 7/12/00
Re: Impossible to use VS2005 with Java?   
Apr 14, 2006 5:50 PM (reply 4 of 12)  (In reply to #3 )

 
Is it possible to copy this manifest into the application directory instead of the java.exe directory? If I ship this manifest with my application it won't have java.exe in the same directory.
 
JaimeMartin
Posts:2
Registered: 4/14/06
Re: Impossible to use VS2005 with Java?   
Apr 14, 2006 6:07 PM (reply 5 of 12)  (In reply to #4 )

 
i would say, no , it is not possible, but test it, may be if the directory where is the manifest is in path enviroment var...

i do not know very well how the manifest files work. Post the result of your tests, i am interested also.
 
KrishnaT
Posts:1
Registered: 7/17/06
JNI, msvcr80.dll   
Jul 17, 2006 3:37 PM (reply 6 of 12)  (In reply to #3 )

 
Hi,
I am run a c++ dll developed with Visual Studio 2005 with JNI interface with jdk1.6 beta2.0. I am having the following problems:
1. if i embed the manifest in my dll and run my java application, the application loads msvcr71.dll.
2. if i do not embed the manifest within my dll and do the stuff explained in this forum, like creating a java.exe.manifest, i get the R6034 error. I tried by creating a folder and copying the mscr80.dll, msvcp80.dll and msvcm80.dll into the folder, but still i get the R6034 error.
Please help me solve this problem. Any suggestions/info is greatly appreciated.
Thanks,
Krishna.
 
jcscoobyrs
Posts:1
Registered: 10/4/06
Re: JNI, msvcr80.dll   
Oct 4, 2006 12:45 AM (reply 7 of 12)  (In reply to #6 )

 
For those of you following the JNI Tutorial, or many of the other JNI resources, on Windows, you may be the "R6034" error if you include the "-MD" compiler flag. Taking this out results in a built dll and it runs without the "R6034". I'm not claiming to understand the situation enough to explain it but as part of my going through the JNI Tutorial, I found this works for me.

Take care,

Jeremy
 
Slawi
Posts:1
Registered: 2/13/07
Re: JNI, msvcr80.dll   
Feb 13, 2007 3:17 AM (reply 8 of 12)  (In reply to #7 )

 
Nice hack!
Thx a lot!

Had same problem,
don?t know what this option "-MD" has changed,
but it helps... suddenly the JNI even works... ;-)
 
Holger_Burbach
Posts:15
Registered: 5/30/07
Re: Impossible to use VS2005 with Java?   
Jun 1, 2007 2:08 AM (reply 9 of 12)  (In reply to #2 )

 
I have a similar problem with Webstart. I try to use Leadtools DLLs (third party graphics library) together with a Visual C++ 2005 Express wrapper DLL. To satisfy library dependecies I have use loadLibrary() to load msvcr80.dll first. Under Windows 2000 everything works fine. Under Windows XP I get the R6034 error message. I have sent an enquiry to Sun. I do not want to bother the user of Webstart with additional installation procedures in addition to installing JRE. Is there any solution for this problem?
 
vitallis
Posts:906
Registered: 8/1/00
Re: Impossible to use VS2005 with Java?   
Jun 1, 2007 7:39 AM (reply 10 of 12)  (In reply to #9 )

 
I have no problem in use JNI with MS VS2005. It runs fine with JDK 1.1.x-1.6.x. I also developed JNI SDK for .NET 1.1/2.0. With it anybody can develop JNI modules in any .NET language. See
http://www.simtel.net/product.php[id]95126[SiteID]simtel.net

If you google "OOJNI" you will be able to download this product from other sites.
 
RD9595
Posts:1
Registered: 10/4/07
Re: Impossible to use VS2005 with Java?   
Oct 4, 2007 2:47 PM (reply 11 of 12)  (In reply to #10 )

 
If you are not using /MD switch, then you are statically linking to the dependent libraries and hence there is no runtime dependency. Thus no manifest file. At least that is what I think. However, I've seen manifest file generating even with /MT switch and wonder what am I missing.
 
Sastry.V
Posts:1
Registered: 10/25/07
Re: JNI, msvcr80.dll   
Oct 25, 2007 2:56 AM (reply 12 of 12)  (In reply to #6 )

 
Krishna, I am having the same problem as yours. I have created a C++ dll using Visual studio 2005. I was trying to load the dll using JNI. The application crashes. JNI is unable to load the C++ dll buid with Visual studio 2005. I tried changing /MD to /MT, but could not resolve it. Can you please tell me how did u resolved your problem. Anybody please suggest/advice me ...... to resolve my problem ???
 
This topic has 12 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 129

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums