How To Call A Third Party DLL ?
Hi All,
I do have a dll file written in C/C++. I need to call it from java.
I do have all the function declarations & descriptions, but not the source of the dll.
I want to call those methods in java. I know that I have to use JNI for this. But dont know how to do it ?
please guide me to do it .
Thanks in Advance.
Matthijs@ wrote:
Just speaking for myself:
It is a bad idea to learn C/C++ using JNI.I'm not trying to learn C++ using JNI. Instead, I have an existing DLL written in C++, and I want to call it from Java. Simple as that. Why do I want to call it from Java? Because I have a lot of existing Java code that I need to integrate with this DLL.
If you already know C/C++ then it should be rather obvious how to do what you stated.I don't know C++, so I guess it's not obvious.
To use JNI you need to know C or C++.
There are alternative wrappers (which actually use JNI dynamically) that have the goal of letting you do it without C/C++.
However the complexity of that comes from understanding that one is still interfacing with a native method which often has a C/C++ structure (figuratively but possibly literally as well.) As the complexity of the native API the chance that someone with no C/C++ experience figuring out the correct way to use it goes down.
You can research jnative (also called JNA) for this approach.
Not however that questions about JNA (or other wrappers) on this forum/site are unlikely to get answers. There might be other sites where that is different. On the other hand JNI will almost always get answers.
As a general programming concept JNI exists to provide a layer between disparate layers. Thus again it should be obvious that one will in fact need to write JNI code to access a native library.Sure. Never said I didn't expect to write JNI code. The thing that bothers me is that the one good resource I found on JNI spends I don't know how many pages explaining how to write the native code with method names like Java_Class_x etc. In my and the OP's scenario the DLL can't be modified, so the immediate question that comes to mind is: if the methods have to be called Java_etc, how can I make this work with my DLL? Of course, perhaps if you sit down and think about it, you might figure out that you can write C++ code that wraps the DLL, and then use JNI to call that code. However, this might not be so easy to figure out for people that are not programming wizards like yourself, and nonetheless have a need to integrate Java with C++. Although I am no wizard, I'm no beginner either (in Java, at least) but I didn't think of it until after reading the relevant chapter (I admit that I then had a slap-forehead "of course!" moment).
Again the point is that you must know C/C++ first.
From the "The Java Native Interface" book from Sun first page of the introduction
"The book assumes that you have basic knowledge of the Java, C and C++ programming languages..."
My point is: since integrating existing code of both languages should be the most common use case for JNI, why not provide an explanation about this scenario up front in the documentation? Something like: "if you have an existing DLL, you will need to write some C++ code that calls that DLL. In the following, we will explain how you can make the C++ code you write yourself callable from Java with JNI. Chapter 9 goes into more detail about how to write wrapper code for existing DLLs." Just so people that are not Einstein and are in a hurry can figure out where to go quickly.
And my point is that what you are stating was immediately obvious the first time I saw the JNI specification.
Anyone that tries to "go quickly" with C/C++ code is going to end up crashing the application (whether it is C/C++ code or JNI code.)
My second point is: the [Guide to Features/JNI|http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html] that ejp urged the OP to Google for is rubbish. Most people don't want a JNI specification, they want a tutorial. The [Java Native Interface tips|http://java.sun.com/products/jdk/faq/jnifaq.html] page is slightly less rubbish, but it still stinks. It doesn't explain anything. Try following the "resources on the Net" links. 3 out of 5 are broken or it is explicitly stated that they are outdated. The other 2 are decent, but again don't provide a straight statement on the most common scenario. Why doesn't either the guide to features or the tips page provide a link to the [JNI Tutorial and Programmer's Guide|http://java.sun.com/docs/books/jni/html/jniTOC.html]?
You would need to provide some actual numbers to support your contention as to what "most people" want.
Most developers never use JNI at all.
As for the spec being rubbish if a developer claimed experience in C and C++ and yet claimed they didn't understand the spec then myself I would question their contention that they actually knew C/C++.
For someone who doesn't know C/C++ then the first step is to learn those.
It would also be handy to have a basic idea of how shared libraries (on any OS) work and how to dynamically use such libraries (versus statically.)
My third point is: why be so rude to the OP almost from the start?Obviously the first question is why you think it is necessary that you need to comment on something that didn't involve you in the first place.
But other than that the posters on these forums answer a lot of questions and the forum is NOT for any of the following
1. Teaching someone how to program
2. Teaching someone how to ask questions
3. Teaching someone how to think logically.
4. Teaching someone how to design.
5. Teaching anyone about etiquette.
6. Anything at all except java.
So for example we do not nor should anyone expect us to teach a beginning programmer how to program in C/C++. And we need not be polite when we tell someone that the forum is not suited for those purposes.
Similar Messages
-
Calling a third Party dll from java using JNI
Hi
I want an immediate help from u all.
I have athird party c dll with .h and .lib file
I wont be able to cahnge any thing in those files.
I want to call the functions of that from my Java code.
Ist possible to call the dll without writing any c or c++ wrapper over it?if yes , how to do it?Hi,
You may use a generic wrapper like JNative.
Commercial wappers also exists.
--Marc (http://jnative.sf.net) -
How to use Third Party DLL in Adobe Illustrator Plug In
Hi Everyone,
I want to design plug-in for Adobe illustrator CS6(64 bit). As first step I am referring sample plug ins from ../SDK/SampleCode. I am not getting how to use third party DLL in plug in.
Please let me know how to refer C# DLL in illustrator plug in.
Thanks in advance.There's no C# API for the Illustrator SDK, so your plugin must be C++ at the very least. That said, you can probably write a bridge if you need to call out to a C# library/DLL.
-
How to add third party dll in our installer using application builder?
Hello friends,
I have one application (VI) which is using some third party dll of protocol and now I want to make a installer which should install dll along with application exe. Please suggest the way ..
Thanks
Solved!
Go to Solution.Hi,
I placed it in project file and included it in category of "Always Included" in exe creation. Then after i created installer with needed NI drivers. But this installer didn't registered the dlls in project file. I registered it manually using regsvr32 command..
Any help to do it automatically during installation..
To brief my words, I need help to understand the process of third party dll registration during installation of installer created by application builder..
Thanks -
How SAP handles AFS Third Party Orders in ECC system?
Hi All,
There is a user exit EXIT_SAPLJ3AM_003 which exist in 4.6C version of SAP for AFS.
This user exit is for Third Party order processes. This is called within the include LJ3AMFD1 of the main program SAPLJ3AM.
But this User exit is missing in ECC version of SAP for AFS.
Basically when the Dierct ship Sales Order is created, corresponding PR is created for it and using this User exit certain fields in this corresponding Purchase Requisition is filled from Sales Order but this user exit is missing in ECC system.
Could anyone please let me know how SAP handles the Third party Orders in ECC AFS system?
Thanks,
AmeeshaHi Ameesha,
Did u find out any solution for it? bcoz, am also hving the same issue!!
thanq -
ADF mobile: How to pack a third party jars into apk
Hi Expert,
I am using Jdeveloper + ADF mobile 11.1.2.4 to develop an android application. In this application, I need to call some functions in the third party jar files. I need to add the third party jars into my apk so that those classes can be found during runtime.
I followed section 17.1.1.1 to add the libraries into my project. However, after I deployed my app to the emulator and tried to run it, it reported "encountered error: classes not found". And I also found that the third party jars don't exist in libs/ directory of the apk. Do you know how to solve the problem: How to reference a third party jar files in my app and make sure it works?
Thanks,
YanCreate a /libs directory within Android project directory and copy the JAR files to /libs.
To build.properties add
external.libs.dir=libs -
Deploying third party dll from solution
Hi,
I am creating a visual webpart in which i have added the Telerik RadGrid.
I have added the Telerik.web.UI dll in the Reference and is refered from the GAC. I have build the solution and grid works fine in my local dev environment.
I would like to know how to package the solution, so that the third party dll is also added to the GAC and to the safe controls.
How to achieve this? If possible, please elaborate the steps.
ThanksHi Mahindrakar,
I have used the right name of the dll in my code. I didn't understand, what you are saying about readme file ?
I getting the following error with
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Certification.VisualWebPart1.VisualWebPart1UserControl.Page_Load(Object sender, EventArgs e) +187
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +41
System.Web.UI.Control.OnLoad(EventArgs e) +131
System.Web.UI.Control.LoadRecursive() +65
System.Web.UI.Control.AddedControl(Control control, Int32 index) +349
Certification.VisualWebPart1.VisualWebPart1.CreateChildControls() +154
System.Web.UI.Control.EnsureChildControls() +145
System.Web.UI.Control.PreRenderRecursiveInternal() +60
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3393
One thing, i know very well, only problem in adding reference only.
The above thing may helpful for you, giving me solution.
Thanks
Aasai. -
How do i enable third party cookies on my macbook pro?
how do i enable third party cookies on my macbook pro?
You mean in a particular browser?
Safari>Preferences>Privacy>third party cookies -
Hi,
I want to convert word document to PDF, EPub, by using third party (.dll).
In SharePoint designer workflow in 2013.
So that I have question, Can we Install third party (.dll) in SharePoint workflow Designer for conversion?
Means I have created one simple application conversion of word to e Pub, PDF, Image by using (Spire.doc dll) in Visual Studio.
So this same conversion I want to work in SharePoint designer workflows?
So anybody has any solution then please provide me.
Thanks,
Samadhanit might be worth looking at these CodePlex steps, that plug directly into the Word Automation Services.
http://sp2010wordautomation.codeplex.com/
It'll provide you with a configurable step like the below that should help you achieve your aims
Steven Andrews
SharePoint Business Analyst: LiveNation Entertainment
Blog: baron72.wordpress.com
Twitter: Follow @backpackerd00d
My Wiki Articles:
CodePlex Corner Series
Please remember to mark your question as "answered" if this solves (or helps) your problem. -
How do I allow third party cookies for a website and how do I turn off pop-up blocker?
How do I allow third party cookies for websites and how do I turn off pop-up blocker?
Allow third party cookies at Safari > Preferences > Privacy > Block Cookies - "Never".
Turn off the pop-up blocker at Safari > Preferences > Security > Block pop-up windows = unchecked -
Where is the right path to deploy third party DLL? "Support Files"?
Hi, After Effetcs developers:-)
Here is question about install path of DLL for After Effects plug-in.
I'm developing Effects plug-in run with CUDA, so I have to deploy third party DLL to client PC.
So where is the right path to put DLL such as cudart32_30_14.dll?
I think it's under "Support Files", because my plug-in runs with cudart32_30_14.dll
in "C:\Program Files\Adobe\Adobe After Effects CS4\Support Files"
Am I right?well... that depends.
when you rely on an external library, the external dll is expected to be somewhere along the path, as it appears in the command prompt.
places like win32, and sxs folders are in that path.
you could also put the support dll in the same folder as your plug-in. any process automatically includes it's own directory in the search path.
if you don't want to put it in any of these pre-set locations, then you have to program the path into the dll loading function.
if you choose to do that, you can put the support dll anywhere you like. -
How to map the Third Party materila for Job Wok process in our Plant
Dear All,
please guide me how to map the Third Party Subcontracting in Our Plant Means Customer materials to be Processed in our Plant and then we have to sent to customer after processing.
please Brief me with the Proces sflow
Reagrds
kishore Edagali1) create a 2 material as non valuated (one incoming material "A1"& after processed material"B1")
2) create a BOM. for A1
& assign the B1 and maintain respective conversion
3) create a routing for A1 and assign the relevant work center
4) create a manual PO to receive the material from customer and store it in storage location
5) create a production order and release the order in co01
6)issue the material :B1 to the order 9 in MB1a, 261 movement)
7) and confirm the order (so that cost incurred for order is captured)
8) create a sale order and maintain service price in PR00 and send the material A1 to customer. -
How can I enable third party cookies?
How can I enable third party cookies?
Demo, I just did some reseach on this question and while one an set iPad to accept cookies, from what I read, it doesn't work for 3rd party cookies. Maybe I'm not getting it though, which is certainly possible..
-
Add third party dll to solution
In my solution/web part, I used a third party dll (newtonsoft.json.dll). I have added the dll to the solution and project level. I do not see the dll when I tried to add a reference. Please see the attached screen shot. Please let me know what is the correct
way to add a third party dll to a SharePoint solution/web part. Thanks lot.(1) I already tried to add the dll from the .NET Framwork 4.5 folder. Then reference the dll from disk location. However, I got a "File not found exception" error.
(2) I search on the web, some people suggest to add the dll as part of the solution. So I added the dll to the solution and project as "exiting item". However, I cannot reference to dll what is in the solution/project (please see my early
post). -
How will i configure third party billing
how will i configure third party billing....
Customize the third party sales in summary:
1. Create Vendor XK01
2. Create Material u2013 Material Type as "Trading Goods". Item category group as "BANS".
3. Assign Item Category TAS to Order type that you are going to use.
4. A sale order is created and when saved a PR is generated at the background
5. With reference to SO a PO is created (ME21N). The company raises PO to the vendor.
6. Vendor delivers the goods and raises bill to company. MM receives the invoice MIRO
7. Goods receipt MIGO
8. Goods issue
9. The item cat TAS or Schedule line cat CS is not relevant for delivery which is evident from the config and, therefore, there is no delivery process attached in the whole process of Third party sales.
10. Billing
SD - 3rd party sales order Create Sales Order
VA01
Order Type
Sales org, distr chnl, div
Enter
Sold to
PO #
Material
Quantity
Enter
Save
SD - 3rd party sales order View the PR that is created with a third party sales order
VA01
Order Number
Goto Item Overview
Item ->Schedule Item
SD - 3rd party sales order View the PR that is created
ME52N
Key in the PR number
Save
SD - 3rd party sales order Assign the PR to the vendor and create PO
ME57
Key in the PR number
Toggle the "Assigned Purchase Requisition"
Execute
Check the box next to the material
Assign Automatically button
Click on "Assignments" button
Click on "Process assignment"
The "Process Assignment Create PO" box , enter
Drag the PR and drop in the shopping basket
Save
SD - 3rd party sales order Receive Goods
MIGO_GR
PO Number
DN Number
Batch tab , click on classification
Serial Numbers tab
Date of Production
Flag Item OK
Check, just in case
Post
Save
SD - 3rd party sales order Create Invoice
MIRO
Invoice Date
Look for the PO , state the vendor and the Material
Check the box
Clilck on "Copy"
Purchase Order Number (bottom half of the screen)
Amount
State the baseline date
Simulate & Post
Invoice Number
*Invoice blocked due to date variance
SD - 3rd party sales order Create a delivery order
VL01N
In the order screen , go to the menu Sales Document , select "Deliver"
Go to "picking" tab
State the qty and save
SD - 3rd party sales order Create a billing document
VF01
Ensure that the delivery document is correct in the
Enter
Go to edit -> Log
Save
Also please go through this Building block
[Third Party Without Shipping Notification|http://help.sap.com/bestpractices/BBLibrary/html/J55_ThirdPartyWOSN_EN_US.htm]
thanks
G. Lakshmipathi
Maybe you are looking for
-
Yoga 2 Pro stuck volume, missing cursor, onscreen keyboard unusable
I'm having several issues with a Yoga 2 Pro laptop running Windows 8.1 that's about a year old. 1) Volume is stuck at 0. I can raise the volume, but it automatically lowers back down to zero, as if the volume-down key is stuck. The volume indicator i
-
How do I change name of Apple Mail
I was calibrating the battery of my MBP and let the battery drain. It went black and then the screen lit up again and then died. It didn't go to sleep. I was working in Mail. I had to restart my computer and my Mail was messed up. I called Apple supp
-
IE 11 and VPN Registration via Citrix Access Gateway not possible
The registration screen for the Citrix Accesss gateway is not displayed when starting the IE 11. Thus, registration is not possible. The side of the IE 11 is blank. https://Access.fks.de/vpn/index.html Kind regards Bernd Joecks
-
Importing from AECS5 to AECS4: Color issues:
Hello, I have a logo created in vector graphics in AICS5. The RGB value of the blue I am using in AI is 0079c1. However, when I import the .AI file into AECS4, the blue turns into 095AA5. I tried to adjust the color management in AE but no luck. What
-
Hello, on BW 3.5 I have defined Jumps in RSBBS for all queries of a cube. It's work fine. (For exemple Jump over MM03) With BI7, these jumps don't work. When I try to use them, nothing happen... no SAP R/3 window, no error message.. I didn't find any