How can java directly access DLL

I have some DLLs that are either written in C or C++ ( no access to source code), I now need to access some objects from it. is there a quick way to do this? are there any libraries already developed to allow my java code to access the objects inside those DLLs directly?
This is to convert some powerbuild code to java and the powerbuilder code is like this":
OLEObject loo_test ;
loo_test.connectToNewObject("AMS5.Almi);
then it just uses loo_test to call the methods and get results
AMS5 is the application name (there is actually an ams5.exe in the directly), and then a whole bunch of DLLs. I do not know which DLL is the code actually using..
any help will be greatly appreciated!

Clearly, at minimum, you need to know which DLLs contain the methods you're interested in. If you look at the JNA example below, it loads a Windows system DLL then contains 'beep', describes how to call it, then calls it. You will need to do something similar:
* JNATest.java
* Created on 24 August 2007, 12:12
package com.sdl;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.win32.StdCallLibrary;
/** @author amalcolm */
public class JNATest
    // Windows XP kernel library
    interface Kernel32 extends StdCallLibrary
        void Beep(int frequency, int duration);          
    public static void main(String[] args)
           Kernel32 kernel32=(Kernel32)Native.loadLibrary("kernel32",Kernel32.class);
            for(int freq=10;freq<10000;freq*=2)
                kernel32.Beep(freq, 5);
}

Similar Messages

  • How can a MDB access filesystem?

    Hi,everyone. Should you help me resolve this problem?
    <b>--How can a MDB access filesystem?</b>
    SOURCE CODE:
    public void onMessage(javax.jms.Message aMessage) {
    try{
    FileOutputStream fos = new FileOutputStream(new File("D:\\Temp\\a.nok"));
    fos.write("testing".getBytes() );
    fos.flush();
    fos.close();
    }catch(Exception e){
    e.printStackTrace();
    RESPONSE:
    java.security.AccessControlException: access denied (java.io.FilePermission D:\Temp\a.nok write)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)
    at java.security.AccessController.checkPermission(AccessController.java:401)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
    at java.lang.SecurityManager.checkWrite(SecurityManager.java:975)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
    at neu.mid.mag.mlm.MsgMonitorBean.onMessage(MsgMonitorBean.java:51)
    at com.sun.ejb.containers.MessageBeanContainer.onMessage(MessageBeanContainer.java:653)
    at com.sun.ejb.containers.MessageBeanListenerConcurrent.onMessage(MessageBeanListenerConcurrent.java:20)
    at com.sun.jms.client.SessionImpl.onSessionMessageListener(SessionImpl.java:981)
    at com.sun.jms.client.SessionImpl.deliverMessage(SessionImpl.java:1072)
    at com.sun.jms.client.JMSClientImpl.sendMessage(JMSClientImpl.java:149)
    at org.omg.stub.com.sun.jms.client._JMSClientImpl_Tie._invoke(Unknown Source)
    at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:350)
    at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:250)
    at com.sun.corba.ee.internal.iiop.LocalClientRequestImpl.invoke(LocalClientRequestImpl.java:96)
    at com.sun.corba.ee.internal.corba.ClientDelegate.invoke(ClientDelegate.java:227)
    at com.sun.corba.ee.internal.corba.ClientDelegate.invoke(ClientDelegate.java:269)
    at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
    at org.omg.stub.com.sun.jms._JMSClient_Stub.sendMessage(Unknown Source)
    at com.sun.jms.service.ConnectionImpl.sendMessage(ConnectionImpl.java:475)
    at com.sun.jms.service.SessionImpl.processOutgoingMessages(SessionImpl.java:1295)
    at com.sun.jms.service.SessionImpl.access$000(SessionImpl.java:45)
    at com.sun.jms.service.SessionImpl$1.activityDetected(SessionImpl.java:1014)
    at com.sun.jms.util.WorkerThread.run(WorkerThread.java:87)

    Hi,
    Hi,everyone. Should you help me resolve this problem?
    <b>--How can a MDB access filesystem?</b>
    SOURCE CODE:
    public void onMessage(javax.jms.Message aMessage)
    ge) {
    try{
    FileOutputStream fos = new
    m fos = new FileOutputStream(new
    File("D:\\Temp\\a.nok"));
    fos.write("testing".getBytes() );
    fos.flush();
    fos.close();
    }catch(Exception e){
    e.printStackTrace();
    This is fine .......
    RESPONSE:
    java.security.AccessControlException: access denied
    (java.io.FilePermission D:\Temp\a.nok write)
    at
    at
    at
    t
    java.security.AccessControlContext.checkPermission(Acce
    sControlContext.java:270)
    at
    at
    at
    t
    java.security.AccessController.checkPermission(AccessCo
    troller.java:401)
    at
    at
    at
    t
    java.lang.SecurityManager.checkPermission(SecurityManag
    r.java:542)
    at
    at
    at
    t
    java.lang.SecurityManager.checkWrite(SecurityManager.ja
    a:975)
    at
    at
    at
    t
    java.io.FileOutputStream.<init>(FileOutputStream.java:1
    9)
    at
    at
    at
    t
    java.io.FileOutputStream.<init>(FileOutputStream.java:1
    1)
    at
    at
    at
    t
    neu.mid.mag.mlm.MsgMonitorBean.onMessage(MsgMonitorBean
    java:51)
    at
    at
    at
    t
    com.sun.ejb.containers.MessageBeanContainer.onMessage(M
    ssageBeanContainer.java:653)
    at
    at
    at
    t
    com.sun.ejb.containers.MessageBeanListenerConcurrent.on
    essage(MessageBeanListenerConcurrent.java:20)
    at
    at
    at
    t
    com.sun.jms.client.SessionImpl.onSessionMessageListener
    SessionImpl.java:981)
    at
    at
    at
    t
    com.sun.jms.client.SessionImpl.deliverMessage(SessionIm
    l.java:1072)
    at
    at
    at
    t
    com.sun.jms.client.JMSClientImpl.sendMessage(JMSClientI
    pl.java:149)
    at
    at
    at
    t
    org.omg.stub.com.sun.jms.client._JMSClientImpl_Tie._inv
    ke(Unknown Source)
    at
    at
    at
    t
    com.sun.corba.ee.internal.corba.ServerDelegate.dispatch
    ServerDelegate.java:350)
    at
    at
    at
    t
    com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:250
    at
    at
    at
    t
    com.sun.corba.ee.internal.iiop.LocalClientRequestImpl.i
    voke(LocalClientRequestImpl.java:96)
    at
    at
    at
    t
    com.sun.corba.ee.internal.corba.ClientDelegate.invoke(C
    ientDelegate.java:227)
    at
    at
    at
    t
    com.sun.corba.ee.internal.corba.ClientDelegate.invoke(C
    ientDelegate.java:269)
    at
    at
    at
    t
    org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.ja
    a:457)
    at
    at
    at
    t
    org.omg.stub.com.sun.jms._JMSClient_Stub.sendMessage(Un
    nown Source)
    at
    at
    at
    t
    com.sun.jms.service.ConnectionImpl.sendMessage(Connecti
    nImpl.java:475)
    at
    at
    at
    t
    com.sun.jms.service.SessionImpl.processOutgoingMessages
    SessionImpl.java:1295)
    at
    at
    at
    t
    com.sun.jms.service.SessionImpl.access$000(SessionImpl.
    ava:45)
    at
    at
    at
    t
    com.sun.jms.service.SessionImpl$1.activityDetected(Sess
    onImpl.java:1014)
    at
    at
    at
    t
    com.sun.jms.util.WorkerThread.run(WorkerThread.java:87)
    First of all in the specificaitons it is recommended not to use the i/o with ejb.So you should avoid doing same.
    Now the exception you are getting is due to the SecurityManager at the server side JVM.In order to make it run you have to modify the java.policy file present with in the JAVA_HOME/jre/lib/security.
    With in this file you add the following entry
    permission java.io.FilePermission "D:\\Temp\\a.nok", "read,write";
    For more details you should refer to the concept of the Security Manager which is not loaded by default in java app but in applets and in server side applications it is made for security purposes.
    Regards
    Vicky

  • How can I regain access to a MAC account? -- Macbook Pro?

    Situation:  My wife has a 13" Mac Book Pro, that we received in May 2011.
    OS: Mac OS X Snow Leopard (not sure which version it came with -- 10.6?)
    My wife's computer had two administrative accounts.  She uses one regularly, and the other is the 'primary' account for downloading updates and such.
    She was unable to figure out how to use Time Machine or any of the other backup software and the like.
    Yesterday, she updated to OS X Lion, and found that a number of the programs that she enjoys using no longer function.
    She wanted to roll-back to Snow Leopard.  After transferring the majority of the 'must-save' files, she put in the install disk again for snow leopard.  This allowed her to start fresh, however, she wants to regain access to those old accounts.  She tried, but, none of the passwords work anymore.  We know what the passwords are; but, they are not working.
    Our ATTEMPTED solution:  She found a site "http://en.kioskea.net/forum/affich-7339…  This site told her to do something in the boot terminal that allowed her to add a new administrative account.
    She tried going into that new admin account and changing the passwords to the other accounts; no joy.  She changes them, but, they are not retained when she logs off or restarts.
    How can she regain access to her old files?

    Open itunes.  Sign into your account.

  • How can I restrict access to add. internal hard drive by account?

    Hello! Okay, so I am my computer's administrator, and I have a secondary 'guest' account that anyone else can use. So, I know that all my data on my main, OS hard drive is secure from the guest account accessing it, but what about the additional hard drive that I have installed?
    I have a good deal of sensitive data and files stored (and aliased) on my second internal drive that I do not care for 'guest' users to stumble upon. How can I restrict access to the secondary storage hard drive from my Guest login account, and/or just plain hide it from it? Surely, there is a need for this that has brought about a solution. Any tips/advice/solutions?
    Thanks!!!
    =)

    Click here and follow the instructions followed by placing the folders and files on the image; if the password is in the keychain, it will be supplied whenever you're logged in.
    (41018)

  • My old computer had itunes and downloaded songs that I put on my ipod. My old computer got replaced years ago without saving hard drive info or passwords and my iPod burnt out and will not activate. How can I get access to my old songs on new computer.

    My old computer had itunes and downloaded songs that I put on my ipod. Well, my old computer got replaced years ago without saving hard drive info or passwords and my iPod burnt out years ago and will not activate. I now have a new computer and iPod and I have an iTunes account on my iPhone5. How can I get access to my old songs on new computer? Are they lost for good? I have no info about my old computer and old account.

    Downloading past purchases from the App Store ... - Support - Apple

  • If I own Adobe Photoshop Elements 12 and have it installed on my computer, how can I get access to Adobe Bridge without a monthly subscription?  Is there a way to use Adobe Photoshop and Bridge without paying a monthly fee?

    If I own Adobe Photoshop Elements 12 and have it installed on my computer, how can I get access to Adobe Bridge without a monthly subscription?  Is there a way to use Adobe Photoshop and Bridge without paying a monthly fee?

    Hi Jaclyn2,
    Please follow the steps mentioned in the kb: http://helpx.adobe.com/creative-suite/kb/error-update-server-repsonding-cs4.html .
    Regards,
    Romit Sinha

  • HT204266 I live in China, have Dutch nationality, and no US address or Credit Card; how can I have access to products from the US iTunes store, in particular music, when such items are not available from the China iTunes store? In general, what are the di

    I live in China, have Dutch nationality, and no US address or Credit Card; how can I have access to products from the US iTunes store, in particular music, when such items are not available from the China iTunes store? In general, what are the differences between countries' iTunes offerings? Does one really need an address and a credit card for any country to be able to access that countries iTunes store? Why these restrictions?

    You cannot.
    You cannot use another countrys itunes store.
    You must be physically locates inside the borders of a country to use that countrys itunes store and a credit card issued in that country with a valid billing address in that country.
    The owners of the distribution rights of movies/music/etc differ by country.  These distributors decide who can sell their content in that country.
    Buy from another source if your countrys itunes store does not carry somehting that you want.

  • How can I direct all my contact form replies (from my website), to my personal email address?

    How can I direct all my contact form replies (from my website), to my personal email address?
    I have embedded the code to my website but would like all of my contact form replies to be directed to my email address. How can I do this by revising the embedded code. Also will I still be able to receive replies after recieving 5000? At this point will I need a premium account?

    Email notifications are a feature of the Basic and Plus account.
    The free account only allows for 50 responses. The Plus (Premium) account allows for 5000.
    Randy

  • How can my laptop access the downloaded files like mp3 and pdf documents which are in my iphone 4G?

    how can my laptop access the downloaded files like mp3 and pdf documents which are in my iphone?

    Yes you will need to NAT at some point to go from private to public address space. Here is a basic configuration if you are interested:
    interface F8
    ip nat inside
    interface G0
    ip nat outside
    ip access-list standard NAT
     permit 192.168.11.0 0.0.0.255
    ip nat inside source list NAT interface G0 overload

  • How can java programs execute automatically when it connects to network

    Good Day dears...
    How can java programs execute automatically when it connects to network.
    Thanks in Advance friends Shackir

    884924 wrote:
    Good Day dears...
    How can java programs execute automatically when it connects to network.What is "it"? That is, execute when what connects to the network?
    Your computer? If that's what you mean, this is not a Java question. It's an OS operational/administrative question. Executing any program, whether written in Java or not, based on some system event has to do with that system, not with the program. If it's possible to do this, you'd do it exactly the same way for a Java program as you would for any other program.
    Or is "it" the program itself? If this is what you mean, then it's a nonsensical question. For the program to connect to the network and detect that it has connected to the network, it must already be executing, so asking how to execute it at that point is meaningless.
    Finally, I'll point out that "connecting to the network" is a pretty meaningless phrase. Or rather, it has so many potentially valid meanings that it's impossible to know which one you're referring to when you use that phrase. And I'd be willing to bet you don't have a clear picture of that yourself.

  • Can I directly access BEX query from web version

    Hi expert,
            Can I directly access BEX query from web version ? I know we can access bex query from webi rich client.
    Many Thanks,

    Hi,
    Yes, you can access BEx query via BICS connection (OLAP Connection).
    In SAP BusinessObjects BI 4.0 you have multiple options to connect your SAP BusinessObjects BI client to your SAP NetWeaver BW system.
    Direct BI Consumer Services (BICS)
    SAP BusinessObjects BI 4.x Relational Universe (UNX)
    SAP BusinessObjects XI 3.1 OLAP Universe (UNV) used in a SAP BusinessObjects BI 4 environment
    Web Intelligence
    Yes
    Yes
    Yes
    SAP BusinessObjects Dashboards
    Yes
    Yes
    No
    Analysis, edition for Microsoft Office
    Yes
    No
    No
    Analysis, edition for OLAP
    Yes
    No
    No
    SAP BusinessObjects Explorer
    No
    Yes
    No
    SAP BusinessObjects Design Studio
    Yes
    No
    No
    Visual Intelligence
    No
    Yes (1)
    No
    Predictive Analysis
    No
    Yes (1)
    No
    Design Studio
    Yes
    No
    No

  • HOW CAN I DIRECTLY WRITE ON NEXT PAGE OF SAPSCRIPT

    HI,
    HOW CAN I DIRECTLY WRITE ON NEXT PAGE OF SAPSCRIPT.
    I want to  call certain fields on next page only is it possible?
    How?
    Regards
    mave

    Hi
    You can use -
    IF &PAGE& = 2. ENDIF.
    But this will work only when you sapscript triggers two pages. Multiple pages can be triggered by main window if the window is filled up. Otherwise you can define two pages statically in your script .
    Cheers.

  • How can I get access back to sounds and lessons I have not downloaded before updating?

    When I purchased my Mac about two months ago, I had access to all of the lessons and sounds, I just had to download them.  I recently downloaded and installed the update and in doing so I lost access to sounds and lessons I had not downloaded.  It tells me that I need to purchase the sounds and lessons package.  How can I get access back since I have already purchased it?

    Apple does not support downgrading the iOS.
    Yes, iOS 7 looks quite different. But there are many new and valuable features. As time goes on you will not remember how it used to look.

  • How can i get access code to create ABAP Program ?

    hi guys ,
    How can i get access code for creating ABAP Program in my System.
    I am using SAP IDES 4.6 Version
    Please Help me out .
    Regards
    Raghu

    Hi Raghu,
    - license your system (http://service.sap.com/licensekey)
    - create a developer key (http://service.sap.com/sscr)
    - create a key for your ABAP program (httP://service.sap.com/sscr)
    Markus

  • How can I give access to a new user for WebView Reporting Log In //IPCC Enterprise

    Hi All,
    How can I give access to a new user for the WebView Reporting Log In ?
    I have IPCC Enterpise 7
    Thanks
    Andres

    Two options: 1. In configuration manager on the AW, use the user list tool to add the users domain account and select Webview access permissions. 2. Using standard Microsoft Active Directory tools or the Cisco Domain Manager tool, add the desired AD user account into one of the "WebView" security groups created within the Cisco OU.

Maybe you are looking for