How would I call a method inside a dll?

How would I call a method inside a dll? Is it even possible in Java? Like in VB you would do something like this: XXX.dll --> XXX.Activate()... I have already loaded the dll like this:
String xxx = "C:/WINDOWS/system32/xxx.dll";
System.load(xxx);
Please help?
THX

I've got another question.
I've gone through the link you posted and a couple others that I found.
I am able to create an interface using the windows kernel32.dll and go through an example I found.
But when I try to use a dll that I have from another application, I have problems.
Here is what I have for the interface.
public interface IAiCamDeviceControl extends StdCallLibrary {
     public IAiCamDeviceControl INSTANCE=(IAiCamDeviceControl)Native.loadLibrary("D:\\IAiCamDeviceControl.dll",IAiCamDeviceControl.class);   
//        public long GetVersion( String s );
//        public long Close();
}The interface that works looks like this:
public interface Kernel32 extends StdCallLibrary {
     public Kernel32 INSTANCE=(Kernel32)Native.loadLibrary("Kernel32",Kernel32.class);I thought that the problem might be using the path name for the library, so I copied it into the system32 directory.
Still get the same error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'D:\IAiCamDeviceControl.dll': The specified module could not be found.
My main looks like
public class Main {
    public static void main(String[] args) {
//          Kernel32 lib=Kernel32.INSTANCE;
//          Kernel32.SYSTEM_POWER_STATUS batteryStatus=new Kernel32.SYSTEM_POWER_STATUS();
//          lib.GetSystemPowerStatus(batteryStatus);
//          System.out.println(batteryStatus);
            IAiCamDeviceControl camDev = IAiCamDeviceControl.INSTANCE;
}The commented part is from the version that worked.
All I attempted to do here was just create an instance of the interface.
Any idea why I can't access the dll?
The dll is the same one that is used successfully in VB, C#, and C++ demo programs, so I suspect it is a good dll.

Similar Messages

  • Error when calling a method inside a form routine...

    Hello experts,
    I am trying to call a method inside a form but it is giving me an error. The error is:
    Access not possible using 'NULL' object reference.
    Anyway, below is my code guys:
    START-OF-SELECTION.
      DATA: main          TYPE REF TO lcl_main,
            old_and_new   TYPE REF TO lcl_old_and_new,
            check_changes TYPE REF TO lcl_check_changes,
            messages      TYPE REF TO lcl_messages.
      CREATE OBJECT: main, old_and_new, check_changes, messages.
          FORM get_orig_contents_of_zts0001                             *
    FORM get_orig_contents_of_zts0001.
      CALL METHOD main->export_old_recs.
    ENDFORM.
    Help would be greatly appreciated. Thanks a lot and take care!

    Before the "START-OF-SELECTION " just add this sentense :
    <b>class lcl_main definition deferred.</b>
    CLASS Definition.
    ENDCLASS.
    CLASS Implementation.
    ENDCLASS.
    START-OF-SELECTION.
    *Do your coding here
    <b>in this way we are deferring the class definition for later</b>

  • EL - How do you call a method that requires a parameter

    How do you call a method that requires a parameter
    In scriplet code here is what I am trying to do
    <%= car.getDefaultColor(car.getCarType()) %>
    How do I do this in EL
    Here is my guess (it generates the Exception described below)
    ${car.defaultColor(car.carType)}
    Here is the Exception I am getting:
    javax.servlet.ServletException: <h3>Validation error messages from tag library c</h3>tag = 'out' / attribute = 'value': An error occurred while parsing custom action attribute "value" with value "${car.defaultColor(car.carType)}": Encountered "(", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||"]
    Any Ideas?
    P.S. If it matters to you, I am using JSTL 1.0 and the code snippets above are actually within the value attribute of a <c:out value="" /> statement.

    How do you call a method that requires a parameter
    In scriplet code here is what I am trying to do
    <%= car.getDefaultColor(car.getCarType()) %>
    How do I do this in ELYou don't. EL is very strict in method signatures. All get methods must be public Type getProperty(void); And all set methods must be public void setProperty(Type t);
    So you will have to re-work your Bean so it does not need an argument to the get method (getDefaultColor()). Since you are calling another method out of car, you might re-write the getDefaultColor method as such:
      public Object getDefaultColor() {
        CarType ct = this.getCarType();
        //then do other stuff
      }If that isn't suitable, then provide a helper method that is used to set the current car type and then call the getDefaultColor:
      private CarType curCarType;
      public void setCurrentCarType(CarType ct) { curCarType = ct; }
      public Object getDefaultColor() {
        if (curCarType == null) throw new IllegalStateException("CarType must be set before getting color");
        //normal work using curCarType
    <c:set target="${car}" property="currentCarType" value="${car.carType}"/>
    <c:out value="${car.defaultColor}"/>It is better to do as little of the data manipulation (setting up the car type) in the JSP as possible, so the first option is better than the second. Also better then the second would be to set the current car type in a servlet or data access object (or wherever) from which your retreive the car to begin with. Manipulatig it in the JSP itself should be your last resort (to keep as much business logic out of the JSP as possible).
    Here is my guess (it generates the Exception
    described below)
    ${car.defaultColor(car.carType)}
    Here is the Exception I am getting:
    javax.servlet.ServletException: <h3>Validation error
    messages from tag library c</h3>tag = 'out' /
    attribute = 'value': An error occurred while parsing
    custom action attribute "value" with value
    "${car.defaultColor(car.carType)}": Encountered "(",
    expected one of ["}", ".", ">", "gt", "<", "lt",
    "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[",
    "+", "-", "*", "/", "div", "%", "mod", "and", "&&",
    "or", "||"]
    Any Ideas?
    P.S. If it matters to you, I am using JSTL 1.0 and
    the code snippets above are actually within the value
    attribute of a <c:out value="" /> statement.

  • How Can I Call a method in iView  ,which is in another iView

    I Have 2 iViews i want to call a method in Iview which is i another iView
    Thanks and Regards
    Prasad.Y

    Hi Prasad,
    first, welcom at SDN.
    Next, let us clarify some wording:
    A <i>PAR</i> is a <i>Portal ARchive</i>. It is a zip in a certain format. It contains a <i>portal application</i>.
    A <i>portal application</i> consists of <i>components</i> and/or <i>services</i>.
    An <i>iView</i> is somehow an "instance" of a <i>component</i>. It is created within the portal. There are <i>no iViews in a PAR</i> (like: "There are no objects in a JAR (but classes).").
    With this in mind, you know that the question does not work, for iViews don't have "methods".
    If you ask how you can call a method of a class belonging to a different component (but within the same portal app), it is no problem at all, each class has access to each other class within the same portal app (in fact, one has to differentiate between public and private part, but we don't want to go so far). To call use a class belonging to (the public part of) a different app, you will have to set the SharingReference within portalapp.xml.
    If that's what you're looking for - great.
    If not, ask again, but far more detailed.
    Hope it helps
    Detlev
    PS: Please consider to reward points for helpful answers. Thanks in advance.

  • How can I call a Method in a Transformation Routine

    Hello Experts,
    How can I call a Method in a Transformation Routine ??
    THNXX

    Hi,
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6090a621-c170-2910-c1ab-d9203321ee19?quicklink=index&overridelayout=true
    It will be help full .
    Regards,

  • How can we call the method of used controller?

    Hi All,
       i created two WDA Applications.( like YWDA1,YWDA2 ) . i am using the component WDA2 in WDA 1.and displaying the one view of WDA2 as popup window in WDA1 on action of one of the input element in the view of WDA1 by using the method l_window_manager->create_window_for_cmp_usage
    I have a button on the view of WDA2 which has appear in the popup window...how can i call the method which has binded to that button....and where should i code that...and i need to assign selected value in the popup window to input elemetn of view  WDA1
    Please help me to resolve this....
    Regards,
    Ravi

    You can not directly call view's event handler from other component.
    create a method in component controller of the second component and in the button click call the component controller method. ( also make the method as interface so that you can call it from other components )
    Now, you can call the interfacecontroller's method
    DATA: l_ref_INTERFACECONTROLLER TYPE REF TO ZIWCI__VSTX_REBATE_REQ_WD .
      l_ref_INTERFACECONTROLLER =   wd_This->wd_CpIfc_<comp usage name>( ).
      l_ref_INTERFACECONTROLLER->Save_Rr(
        STATUS = '01'                       " Zvstxrrstatus
    save_rr is the method of second component controller

  • Calling abstract method inside constructor

    what will happen if you call abstract method inside a constructor ?

    AMARSHI wrote:
    Then wat is the purpose of that object then.
    When u create an object then the control will move to the default constructor,If there is one. Not all classes have default constructors. Some c'tor will be called though.
    inside the constructor u r having an abstract method.
    But theere are 2 cases now:
    1 the top-level class is an abstract class
    2 the abstract class is an inner class.
    1. for case 1 , u cannot create an object ,so no need of having the constructor.Yes, you can create an object. You can instantiate a concrete subclass. The abstract parent's constructor is still called, and that c'tor may call an abstract method, which will be implemented in the concrete subclass, or some class between it and the parent.
    2.for case 2 u cannot have an object like:
    outerClass obj = new innerAbstractClass()I have no idea what you're talking about here.

  • How do you call a method from  another class without extending as a parent?

    How do you call a method from another class without extending it as a parent? Is this possible?

    Why don't you just create an instance of the class?
    Car c = new Car();
    c.drive("fast");The drive method is in the car class, but as long as the method is public, you can use it anywhere.
    Is that what you were asking or am I totally misunderstanding your question?
    Jen

  • My brother and I will both be in Quito at the same time but staying in different hotels. If we both have facetime how would we call each other (over wifi of course)?

    My brother and I will both be in Quito at the same time but staying in different hotels. If we both have iphones with facetime how would we call each other (over wifi of course)?

    Hello ajs42548,
    The article linked below details how to go about using FaceTime. In order to use FaceTime over Wi-Fi, just verify that you are connected to a Wi-Fi network prior to initiating the call.
    iOS: Using FaceTime
    http://support.apple.com/kb/HT4319
    Cheers,
    Allen

  • Call native methods from windows dll

    Hello all,
    I want to call BlockInput method from User32.dll. My source code looks something like this:
    public class User32Dll_1 {
         static {
              try {
                   System.loadLibrary("User32");
              catch (Exception ex)
                   ex.printStackTrace();
         public static void main(String[] args) throws UnsatisfiedLinkError {
              BlockInput (true);
         /** @param b
         * @dll.import("USER32")*/
         private static native boolean BlockInput(boolean bBOOL);
    And the problem is that I get the following exception:
    java.lang.UnsatisfiedLinkError: BlockInput
         at User32Dll_1.BlockInput(Native Method)
         at User32Dll_1.main(User32Dll_1.java:27)
    Exception in thread "main"
    Can someone provide me a solution for this?
    Thank you in advance!

    can't do
    use JACOB
    http://danadler.com/jacob/
    or
    http://www.ezjcom.com/

  • How can I call a method for all instances of a certain class?

    Hi,
    I have created a snake java applet, which you can play here [http://users.telenet.be/javagames/|http://users.telenet.be/javagames/].
    But now I want to make this into a multi-player game (with two or more snakes etc..).
    In my main class you can find methods like these:
    snake.move();
    snake.drawSnake();Now if I just alter my main class and make a second instance of the class snake and change my methods to this,
    snake.move();
    snake2.move();
    snake.drawSnake();
    snake2.drawSnake();my game almost works perfectly, I'll have to make some minor changes though.
    But my question is, is there a better way of doing this. Instead of duplicating all the code, how can I make the methods immediately work for both snakes, instead of calling it twice?
    All suggestions are welcome!
    Thanks in advance.
    Lennart

    If there was something common to all snake instances then you could declare that variable static.
    Note: I don't want to confuse you here. A static variable can have a value apart from any instances at all. Instances can view static variables but a static method or inner class, for example, cannot view instance variables.
    More generally, I would think you would want to treat each snake as an automaton with its own behavior. There must be some class such as Game or Board or whatever that has, as suggested, either an array or collection of snakes. Iterate over each snake, ask it to perform some computation for the game and then draw itself.
    - Saish

  • How we can call java methods in ODI?

    Hi
    i have java jars.i would like to call java methods from ODI
    how it is possible in ODI?
    plz help me regards the same
    thanks

    Hi
    i tried according to given contents in this link
    but in my systen i am getting error
    could y plz help me regards solving this error
    error is :
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 1, in ?
    java.lang.UnsupportedClassVersionError: FileWrite (Unsupported major.minor version 50.0)
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.access$100(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at org.python.core.SyspathJavaLoader.loadClass(SyspathJavaLoader.java)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at org.python.core.Py.findClassEx(Py.java)
         at org.python.core.SysPackageManager.findClass(SysPackageManager.java)
         at org.python.core.PackageManager.findClass(PackageManager.java)
         at org.python.core.SysPackageManager.findClass(SysPackageManager.java)
         at org.python.core.PyJavaPackage.__findattr__(PyJavaPackage.java)
         at org.python.core.PackageManager.lookupName(PackageManager.java)
         at org.python.core.imp.load(imp.java)
         at org.python.core.imp.import_next(imp.java)
         at org.python.core.imp.import_name(imp.java)
         at org.python.core.imp.importName(imp.java)
         at org.python.core.ImportFunction.load(__builtin__.java)
         at org.python.core.ImportFunction.__call__(__builtin__.java)
         at org.python.core.PyObject.__call__(PyObject.java)
         at org.python.core.__builtin__.__import__(__builtin__.java)
         at org.python.core.imp.importOne(imp.java)
         at org.python.pycode._pyx0.f$0(<string>:1)
         at org.python.pycode._pyx0.call_function(<string>)
         at org.python.core.PyTableCode.call(PyTableCode.java)
         at org.python.core.PyCode.call(PyCode.java)
         at org.python.core.Py.runCode(Py.java)
         at org.python.core.Py.exec(Py.java)
         at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
         at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:144)
         at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    java.lang.UnsupportedClassVersionError: java.lang.UnsupportedClassVersionError: FileWrite (Unsupported major.minor version 50.0)
         at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
         at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)

  • How do I call these methods?

    This is an incomplete program so far but for some reason where I write the statement to call the method its an error (Quartersa(); [Quartersa(double) in addcoins.AddCoins cannot be applied ( )]). What is it that I'm doing wrong? The error is at the bottom of the code.
    Heres what ive been working on:
    package addcoins;
    import java.util.Scanner;
    * @author HP_Owner
    public class AddCoins {
        /** Creates a new instance of AddCoins */
          public static void Quartersa(double quarters){
            quarters = .25;
       int quarteramount;
       System.out.println("Qaurters:");
       Scanner input = new Scanner(System.in);
    quarteramount = input.nextInt();
    quarters = quarteramount * 025;
    System.out.print( quarters);
        public static void Dimesa(double dimes){
            dimes = .10;
       int dimeamount;
       System.out.println("Dimes:");
       Scanner input = new Scanner(System.in);
    dimeamount = input.nextInt();
    dimes= dimeamount * .10;
    System.out.print( dimes);
        public static void Nickelsa(double nickels){
            nickels = 0.5;
       int nickelamount;
       System.out.println("Nickels:");
       Scanner input = new Scanner(System.in);
    nickelamount = input.nextInt();
    nickels = nickelamount * 0.5;
    System.out.print( nickels);
        public static void Penniesa(double pennies){
            pennies = 0.1;
       int pennyamount;
       System.out.println("Pennies:");
       Scanner input = new Scanner(System.in);
    pennyamount = input.nextInt();
    pennies = pennyamount * 0.1;
    System.out.print( pennies);
        public AddCoins() {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
        Scanner input = new Scanner(System.in);
        System.out.println("Enter your total coins:");
    Quartersa(); //ERROR HERE
      Edited by: tetris on Feb 2, 2008 10:03 PM

    I think this is the problem
    System.out.println("Enter your total coins:");
    Quartersa(); //ERROR HERE
    you would need to put something inside the parenthesis here Quartersa();
    something like this might work...
    System.out.println("Enter your total coins:");
    int num=input.nextInt();
    Quartersa(num);
    good luck i hope it works.

  • Call a method in VB dll from Java Web Application

    Hi,
    I'm trying to call a method of a VB dll, from a web application developing with J2EE. Is it possible without JNI? And, if it is not possible with a tool, can you help me with an example of JNI using?
    Thank you
    Mary

    maria_eg wrote:
    I'm trying to call a method of a VB dll, from a web application developing with J2EE. Is it possible without JNI? Maybe using Runtime#exec() and rundll32.exe. Depends on the DLL which you want to call.
    And, if it is not possible with a tool, can you help me with an example of JNI using?JNI tutorial: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
    JNI forum: http://forum.java.sun.com/forum.jspa?forumID=52

  • How do I call a method of an instance of an interface?

    I create an instance of a class that implements the Uncmin_methods interface:
    Uncmin_methods optFunctions = ( Uncmin_methods ) new Optimizer( epsilon );
    Then I want to do something like:
    optFunctions.setDesiredProbRow( desiredProbRow );
    But the stupid compiler won't let me call one of Optimizer's methods.
    Is optFunctions a Uncmin_method object or an Optimizer object?
    How could I update the optFunctions object with some dynamic data?

    But the stupid compiler won't let me call one of
    Optimizer's methods.The compiler isn't "stupid". It knows the rules of the Java language better than you or I do. If it won't compile, better figure out why. I can't tell you, because "Optimizer" and "Uncmin_method" are presumably your own home-made interfaces/classes which I wouldn't know about.
    Is optFunctions a Uncmin_method object or an
    Optimizer object?See last sentence above.

Maybe you are looking for