Is it possible to call a non-JNI DLL

I have a DLL I'd like to execute from Java, but do not have access to the source. From what I've read about JNI, it seems it requires Java specific code in the DLL source. Is there any other option? I need to pass it a String and it returns a String. Is Runtime.exec a viable option?
Any advice would be greatly appreciated.

OK... here is a scenario with some code snippets. I've done this with a C/C++ dll on windows....so if ur on some other OS you'll have to make appropriate changes(ditto for DELPHI).
I have a dll called "myold.dll" written in C/C++ which has the following function signature
int getVersion();
My purpose is to call this function in the dll using JNI.
For this you will need
1. Header file of myold.dll (say myold.h)
2. .lib file for myold.dll (say myold.lib)
Now, write a java file "Mynative.java"
public class Mynative {
public native int getVersion();
   static {
      System.loadLibrary("Mynative"); //matches name of  new dll you are about to create
   public static void main(String[] args){
      Mynative nativity = new Mynative();
      int version = nativity.getVersion();
      System.out.println(version);
}after compiling the above code, you will need to run javah
on the resulting class file
javah -jni Mynative
Now you will have a header file Mynative.h which looks like
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Mynative */
#ifndef IncludedMynative
#define IncludedMynative
#ifdef __cplusplus
extern "C" {
#endif
* Class: Mynative
* Method: getVersion
* Signature: ()I
JNIEXPORT jint JNICALL Java_Mynative_getVersion
(JNIEnv *, jobject);
#ifdef __cplusplus
#endif
#endif
Now create a C file say myCfile.c as follows
#include <jni.h>
#include "Mynative.h"
#include <stdio.h>
#include "windows.h"
#include "myold.h" //Header file of the existing dll..you need this file!!
JNIEXPORT jint JNICALL
Java_Mynative_getVersion(JNIEnv *env, jobject obj)
jint myInt;
/* Call native function in Mynative.dll */
myInt = getVersion();
printf(myInt);
printf("\n");
return myInt;
Now compile this file using a C compiler to create "mynative.dll".You'll have to know how to do that using whatever C/C++ compiler you use.
This dll should be in any folder thats on the Java Classpath or else you are going to get an error.
Well..you're set. You can run the java file and see the output.
If however you do not have the header file for myold.dll, then you'll have to know how to dynamically load a dll in C/C++. Unfortunately, i don't know how so u'll have to ask someone else.
Hope my efforts here don't go wasted. Good luck
Vinny.

Similar Messages

  • Is it possible to call the jar from dll

    Hi,
    I am new to JNI, so please sorry if my question seems trivial.
    I would like to know if is it possible the inverse task, to call java(jar) from dll.
    Thanks

    Thanks for reply,
    I searched in forum threads and found necessary disscussions on this topic, and tried to call java class from c++, but after
    CreateJavaVmProc JNI_CreateJavaVM =(CreateJavaVmProc)::GetProcAddress("C:\\Borland\\JBuilder2006\\jdk1.5\\jre\\bin\\client", "JNI_CreateJavaVM");I am having
    error C2664: 'GetProcAddress' : cannot convert parameter 1 from 'char [46]' to 'struct HINSTANCE__ *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe.error

  • Possible problem calling java from Windows DLL

    I'm am developing on Windows NT 4.0 using JDK 1.3.1.
    What I want to do is to create a DLL that calls into java using the Invocation APIs.
    I am able to successfully create a JVM inside my DLL and find the java classes that i need. The problem is if one of those java classes happens to perform a JNDI function (e.g. InitialDirContext), my DLL doesn't ever return from a call to that class's method.
    Does anyone have any suggestions?

    Thanks for your reply.
    All my JNI functions return ok with out error/exception. The problem is, the one function never returns so that I can check for errors/exceptions.
    I found a work around for the problem. For some reason if I wrap the JNI code in a C++ class, the call hangs. But if I pull that code outside a C++ class, it works like it is supposed to. Not sure why this would be the problem.
    Thanks again for your reply

  • Is it possible to call a class in a jar file from JNI environment?

    Hi
    Is it possible to call a class in a jar file from JNI environment?
    Thanks in advance.

    Could you explain a bit more what you are trying to do? (In other words, your question is vague.)
    o If your main program is written in C, you can use JNI to start a JVM, load classes from the jar of your choice, and call constructors and methods of the objects defined in the jar.
    o If your main program is java, and has been laoded from a jar, a JNI routine can call back into java to use the constructors and methods of classes defined in the jar(s).

  • Is it possible to call c# dll using JNI

    Using JNI we can invoke native code written in c or c++.
    Steps:
    1) All we have to do is write a class and have a method of type native.
    2) Invoke javah with -jni option to create a .h file.
    3) Include this header file and implement the method in c or c++ code.
    Now my question is:
    Is it possible to call I want to know whether we can implement the native method in c# instead of c or c++.
    Thanks

    No you can't, but you can have the JNI C/C++ code call C# code. How to do that is no longer a JNI question but a C# question.

  • Is it possible to call VB dll in Java

    Is it possible to call VB dll in Java?
    If yes then How?

    If you mean VB6 than you can call VB Module like a COM object with any Java-COM bridge.
    VB.NET could be called with my Object-Oriented JNI for .NET 1.1/2.0:
    http://www.simtel.net/product.php[id]95126[SiteID]simtel.net
    http://www.simtel.net/product.php[id]98653[SiteID]simtel.net

  • Possible to add a non-Apple signal booster to Airport Extreme to improve signal strength?

    Good day to you all.
    This might seem like a weird question. I've just rencently purchased my first ever MacBook Pro to enter the Mac family
    With it, I also bought an AirPort Extreme. Like others today, I've had a lot of trouble trying to get the thing set up. I somehow managed to get it working, but the signal strength in the far room of the house is too weak.
    I suppose I could just get a better Wi-fi adapter for that computer to pick up the better signals, but, my question is:
    I have a signal booster (repeater?) from Cisco/Linksys that I used for my Cisco/lynksys router. It would connect to the network and bounce that signal from that base off to improve the signal strength to the rest of the house. It worked like a charm. So, my question is is it at all possible to connect a non-apple booster like this to the network to bounce the signal?
    I assume it would work, but thought I'd ask anyway just to be sure; to check if anyone else knows about this. I'm going to try sometime soon if this works, but would love to know what others think.
    Thank you very much for your time and help!!

    Ah, yes. Good idea. Well, in a few year's time, we'll probably move on to better devices, but, for those who do have something that isn't Apple...I encourage you to try it.
    I'm using the Cicsco/Lynksys Range Extender that I believe is simply called RE1000; mine was refurbished, too.
    Anyway, it came with a set up disc that I'm not entirely sure if it works on a Mac computer. I didn't try it.
    You'll run the set up disc (somehow), make sure you follow the instructions on the screen, and it should allow the RE1000 to find the network you created using the AirPort. Once the set up is complete, it'll ask you to move the RE1000 to another electrical outlet in your house that can take the signal and bounce it to a wider area of your house, and presumably the neighborhood (secure your network).
    Seemed to work without a hitch. So, if you're not using an Apple range extender (another AirPort type thing), hopefully this helps you. It did work for me, otherwise I would have taken the AP Extreme back for a refund haha

  • Is it possible to call the Print Quote functionality from Custom ADF page

    Hi,
    We are researching if it is possible to call the Print Quote functionality from the Custom ADF application.
    Goal is to pop up the PDF report upon clicking the Print Quote button on the custom page. Is it possible ?
    Atleast advice on the direction to go forward is appreciated.
    Thanks
    Sai

    Hi ,
    Please check following thread on forum -
    Re: ADF: Calling OAF Page from ADF page
    Check this may also be useful-
    https://blogs.oracle.com/shay/entry/to_adf_or_oaf_or
    I have not tried yet but Steven Chan (Sr. Director OATG) suggest following methodolgy for this-
    https://blogs.oracle.com/stevenChan/entry/appsdatasource_jaas_ebs
    Thanks,
    Ashish

  • Is it possible to call ms-dos command in abap program?

    Hi,
    is it possible to call ms-dos command in abap program?
    Thanks.

    Hi Cemil,
    You probably have your answer here:
    [Re: DOS/Windows command in app server;
    You create your external command with SM69 (you can test it with SM49).
    Then you call this command with function module "SXPG_COMMAND_EXECUTE".
    (See function group SXPT for all the calls to external commands).
    Regards,
    Thomas

  • Is it possible to call a adobe form inside a function module?

    Hi gurus,
    i am trying to generate the pdf data source inside a custom function module,
    the function module will call the FUNCTION 'FP_JOB_OPEN' , then call the function module of the pdf interface. then get the pdf data back and return.
    but at run time i got the error message:
    FPRUNX101, the job already started.
    then the program stopped.
    i checked the service market place, there is a note for that:858325 Message "Job already started" when you display PDF forms .
    according to the notes,it seems that it's only possible to call the pdf generated function module in a program.
    my question is , is there a way to call that in a funciton module?
    best regards.
    Jun
    the note states that:
    Reason and Prerequisites
    At runtime, a PDF-based form is called using a generated function module. If you use the new interface, it is necessary to set the function modules FP_JOB_OPEN and FP_JOB_CLOSE as control structures with one or several generated function modules. In order for the single test from Transaction SFP to work simultaneously, however, the system checks for the test environment of Transaction SE37 (in which the test ultimately runs) in the single test. In this case, the function modules FP_JOB_OPEN or FP_JOB_CLOSE are called automatically.
    If you then test a function module that calls a PDF based form and therefore calls the function module FP_JOB_OPEN itself, this leads to the error message mentioned above.
    Solution
    The test should be carried out using a program that in turn calls the function module to be tested.

    sorry, i found out the reason.
    the fm can not test direct in se37, it should be wrapped by a program.
    br.
    zj

  • Is it possible to call a VI that is inside a LabVIEW executable from a TestStand sequence?

    I have created a custom TestStand operator interface and have modified the default sequential process model to display a UUT information dialog that prompts for more information than just the UUT serial number.  This UUT information dialog is a LabVIEW VI.  To distribute the operator interface, I build it into an executable.  As part of the build process, I make a copy of the UUT information dialog VI (which is part of my operator interface project) and place it in the same folder as the executable.  I have then configured the sequential process model to call the dialog VI from this location.  It would be really nice if I could embed the UUT information dialog VI inside the operator interface executable so that I could distribute just an executable instead of an executable and separate VIs.  Is this possible?  In other words, is it possible to call a VI that is inside a LabVIEW executable from a TestStand sequence just like a standard LabVIEW VI call?

    Ryan,
    The dialog that you've created isn't being directly called by the OI at all and shouldn't need to be included in the same directory as the OI for distribution. Since you are modifying the PreUUT of the default process model, you will give the path to the VI in that step, create a deployment and then manually copy the VI to the directory referenced in the step. The VI is considered a support file for the process model and is not related to the OI at all.
    Test Engineer - CTA

  • Is it possible to call a 9i Forms from a 6i Forms ?

    Hello,
    I have a customer using CRM 11.5.10.2 ( Database 9.2.0.6 / 6i Forms) and will be created a functionality in the CRM screen, where end user will call (via button) a custom application running on 9i Forms.
    Customer believes that there is a technical limitation to achieve that. That is, call a 9i Forms from a 6i Forms.
    Is it possible to call a 9i Forms from a 6i Forms ?
    Thank you in advanced for help,
    Marcos Souza.

    I should have thought so, as Forms 9i is exclusively web-driven, so how you launch the URL is immaterial as long as you use a supported browser. As your Forms 9i apps will invariably be on a remote web server, you'll not encounter compatibility issues either. And Forms 6 and 9 development is possible on the same PC using multiple Oracle Homes. Ask Oracle beforehand if you are still not convinced.

  • Is it possible to call custom designed RFC function module, apart from BAPI

    Hi Friends,
    1.     Is it possible to call custom designed RFC function module, apart from BAPI.
    2.     Why we call it Adaptive RFC layer, Since every time the JCO layer updated with SAP, Why can’t be dynamic.
    Thanx for Ur time.
    Cheers,
    Sam

    Also check <a href="http://help.sap.com/saphelp_nw04/helpdata/en/41/38bc8f813719488ddc9d9b21251ec3/frameset.htm">here</a> for more information on aRFC. Here you can find why it is called adaptive.
    Regards,
    Christophe

  • HT5071 Is it possible to call a locally installed ibook from a hyperlink? What about to a bookmark?

    Is it possible to call a locally installed ibook from a hyperlink? What about to a bookmarked page?
    I have 2 questions..
    1. Can I send a link via email that when launched will open an ibook that has already been downloaded to the bookshelf?
    2. If question 1 is possible, can I take it a step further and call a bookmark, i.e. chapter 3.
    Our company has it's own appstore and I want to send out links to sections of the ibooks using bookmarks or at the very least take them to the start of the ibook.
    I don't need to give them a link to install the ibook as they already have it installed.
    Any help would be much appreciated.
    Chris.

    That would be cool, but it's not possible. The ibook is not accessible by URL in the user's bookshelf.

  • Is it possible to call the contact number indicated in the cell?

    Hello! Tell me please, I want to move a lot of contacts in the electronic form and organize a list of contacts in Numbers. Is it convenient to use it on the iphone? Is it possible to call the contact number indicated in the cell? That is an example: name, contact, etc. A few columns. I click on the number of human cell, and then what would happen if a set of user (as it happens in the notes for example)?
    Sorry for my english.

    Your post is now in the iWork for iOS community. You should be able to get to it using the link in the email you receive with this message.
    Regards,
    Barry
    PS: Interesting that I received the notification of your post in Russian (except for the first and last words).
    Here's Googles translation of my reply above:
    Ваше сообщение в настоящее время в IWORK для IOS сообщества. Вы должны быть в состоянии добраться до него по ссылке в сообщении электронной почты вы получите с этим сообщением.
    С уважением,
    Барри

Maybe you are looking for