Using Windows API in Java

hi,
How can i use windows api in java.
regards
Malik Faisal

By writing a wrapper in JNI.
JNI Tutorial.

Similar Messages

  • How to use excel api in java?

    I need to use excel api in Java to generate data in excel format. Can any one tell any of the use ful Excel api that we can down load from net? i have read about Apache's POi-hssf-Java api. But the jar i downloaaded from Apache site is not working ? Can anybody please send me the jar for taht Api ?

    Hi,
    In fact i was not clear about whcih jar file to download from the apache site. i found one folder structure like this
    -parent
    -bin
    -src
    All these folders contained some zip files. i took the zip files and extracted them. And i set teh class path also . But when i tried to import in java programs ,these jar files are giving compilation errors

  • Using Windows API in my LabWindows CVI code

    Hi all.
    I would like any and all help. I am developing on LabWINDOWS 2010 and am trying to use the Windows API, particularly the multimedia APIs, in my CVI code. What I am trying to do is audio development, only it has to be in .NET or Visual C++ platform. I have developed the code and UIR, but when I build the solution it tanks on me. Of course when I use MS Visual C++ 2008 or 2010 there are no errors and I could use MS Visual C++ to develop my application, but the development of the user interface and the controls is much more straight forward with CVI and there are more controls to work with than there are with MS Visual C++. Most of the errors that I get are related to the following header files: "MMSystem.h", "devicetopology.h",  and the "endpointvolume.h". When I try and build a skelton project with no controls or indicators on the .UIR I get the errors like:
    "devicetopology.h"(2301,20) Missing parameter type.
    "devicetopology.h"(2301,40) syntax error; found '*' expecting ')'.
     "MMSystem.h"(151,1) Unrecognized declaration.
    "MMSystem.h"(850,96) syntax error; found 'identifier' expecting ')'.
    That is just a few of them, but they typically say the same thing. I have included the header files and libraries in my project, and  have made sure that they are in the CVI "sdk" directory. I have tried example code that have these header files and the result is still the same. I know that I should not have these type of issue, at least I don't think I should. Like I said I could use as much help as possible of figuring out what is the matter. Did I install the CVI improperly? Are there patches that I need to actually use windows APIs? I am attaching to this post my code and the code I downloaded from a LabWINDOWS forum. When I ran the code from the forum I got the same errors.   
    Thanks in advance.
    Attachments:
    AudioVolume.c ‏2 KB
    VISTAS-OpenAL.c ‏44 KB

    Humphreyy,
    thanks for the tip. I tried it but it did not work, the same errors were present. Are there any other suggestions. I have racked my brain to figure out why this is happening and have come up with nothing. I am also getting a "Warning" message concerning the "KsMedia.h" file that says "Warning: Excess characters in multibyte character literal ignored." The warnings trace back to the "typedef enum" section of that file. Could that be causing a ripple effect that produces the error I am seeing in the other header files I mentioned??
    I could really use your help and any more help that is available. I really don't want to use Visual C++, because this software is going to get more sophisticated and is to be used in NASA Langley's VISTAS simulator, an environment taylor made for National Instruments software.

  • How do i invoke Windows APIs in JAVA??? Please help.

    Is there a way to invoke Windows APIs in Java??? Please help......Thankx

    Short answer, you don't. However, you should look at Java Native Interface (JNI) very closely. It will allow you to wrap the Win32 API calls so that Java can call your wrapper methods. Another side to it, although not necessarily related to your question is a JavaBeans to COM bridge that you may want to look into as well, though it's probably not going to be a solution for what you're wanting to do right now.

  • LV memory leak - How to use windows API SetProcessWorkingSetSize (from Kernel32.dll)

    Hi fellow LV'ers
    Okay - this is a bit tricky, but i'll try and explain the problem, then ask for the solution, because it may be that someone knows a better way to deal with this.. might get a bit long, sorry - if a solution comes up this will enable all of us to make more memory efficient LV code so please read on..
    Here is the deal:
    When building even a very simple LV executable, looking at the windows task manager will yield a rather large amount of memory allocated for such a small program - and the only way to free this up is by physically clicking the windows minimize button, then suddenly the amount drops to only a few MB and upon maximizing the window again the memory consumption will increase somewhat again, but for a simple VI build to an exe this move may change the consumption from +70MB to less than 15 MB.. This is irregardless of the code you put in the VI, so no coding example in this post as it is how LV works - you can even test it with the development environment - look at the task mgr and check LabVIEW's memory consumption, minimze ALL open NI windows incl project explorer etc, and you will see a significant decrease in memory usage even after maximizing again.. This has annoyed me since day one, but since RAM is a near zero cost these days it is not something I stay awake at night to think about.. However - I have moved into the "publish to web" tools now, wanting to do a remote monitoring part for my application for my customers to experience increased usability from the software i sell them..
    All is well, publishing is really easy (i use the monitor function, NOT the embeded, as customers need not have Labview RunTimeEngine installed, because they might look at it from a non RTE supported platform such as a mobilephone web browser)
    Everything is working fine also for the build application. However - I have noticed that once users start to remote monitor the running application - memory consumption of the running LV application starts to increase - and it keeps doing so - to such an extend that you can drain the computer complete and run off the cliff with a windows error... This is off course not very productive for me, being specialized in measurement applications that usually runs for a long period of time - I initially thought that I had done some poor programming in the VI used to display on the webpage - but it turns out that I can reproduce this behaviour with a simple boolean on an empty front panel..
    NI support has been informed, and they admit there is a problem, but so far solutions from them has been a bit too exotic for my taste, and thus I'm seeking the help of fellow LV programmers...
    You see - The method to solve the increasing memory consumption, is the exact same as mentioned above..minimize the application running with the "minimize" button and all memory will be freed, as soon as you maximize the application and users are viewing it remotely, the memory usage raises again, and history repeats... As previously mentioned, minimizing the window via normal LV calls to property nodes does not yield the same result, nor does a request deallocation of a VI(When you profile a project, there are no VI's increasing in memory, it is the LV process it self doing it) 
    After many many hours googling I stumbled upon this:
    http://support.microsoft.com/?kbid=293215
    I believe trimming the process with SetProcessWorkingSetSize would solve this problem, and now I would really like to be able to do this in my program, so that users are not forced to minimize the program every X hour depending on their system size...
    However - I have absolutely NO experience in calling windows API from LV, i need someone with that knowledge to provide an example of how to call this.. I've looked at examples on how to do calls to windows API - there is an example in this forum with some llb's in it, and I have gained a fair understanding of how parameters are passed between the calls, but none of those include the "hProcess" handle that is apparently needed for this specific winAPI call to work - Anyone in this forum with the knowledge on how to obtain this handle from a VI, if at all possible, and could provide an example VI for me to use - or even better , someone with the knowledge of how to do this within LV it self??
    Your help is much appreciated
    Best Regards
    Jacob
    LV8.6.1 patch something
    Win XP 
    Solved!
    Go to Solution.

    Hi Enrico
    Finally I can give something to the community that has given me so much  :-)
    The "official" statement is that "yes we know it is a problem".. Not sure what that will do to the future.. 
    I have the problem on 8.6.1 as well  - and in fact it is a general LV problem, that I first time reported to NI with LV8.2 as I was pissed by the fact that even the smallest exe file would consume + 50MB of memory until you manually minimized the window. Well - thanks to the feedback from Cosmin I seem to have solved the problem.
    I most warn that having started to "empty process" once in a while has led to occasional program crashes in the lethal "app.exe performed an illegal action and is closed" windows dialog - however what I did was to move the webserver to a seperate exe file and then communicate the data that I want to use via datasocket in a cluster.. It works like a charm and I simply stall the single thread that the webserver is running when ever the empty process is called and I have not seen a crash since then.. (the initial implementation was done in the main app with 4 parallel loops running, and I guess that was a disaster waiting to happen)
    Either way - what I have done is made a VI that at a user defined interval calls the empty process, simply by getting the .exe name from the task manager of the calling program - it is simple and very effective. I call it every 5 minutes - needless to say that flushing too often will most likely kill performance of the system. I have not noticed problems with VM - are you sure you are not storing large arrays or moving around copies of data not used frequently?
    For future reference to this forum, it is attached here including the .dll required to call - it is a LV8.6.1 file as I have not had the time to yet again test every single function of my program for new problems that could occur with upgrading to LV2009 
    I hope this solves your problem..
    best regards
    Jacob
    www.10EaZy.com 
    Attachments:
    EmptyProcess.zip ‏32 KB

  • Using WD APIs in Java Programming

    Hi,
         First let me explain my scenario:
              I have to get the <b>attachments in a PDF document</b>, using a <b>java program</b>. I am using Java perspective of NWDS. I am using the APIs
    ->IWDPDFDocumentHandler
    ->IWDPDFDocumentAccessibleContext
    ->IWDPDFDocument
    ->IWDPDFDocumentAttachment
    in my program.
    When I run my java program, I am getting the <b>java.lang.NoClassDefFoundError</b>.  Can you please, give me a solution for this problem?
    Note :  I have added the necessary JAR files to the project.
    Thanks,
    Prabhakar.

    Hi Sumit,
       Here is the result which I got in the console,
    java.lang.NoClassDefFoundError: com/sap/tc/webdynpro/services/exceptions/WDRuntimeException
         at PDFAttachment.readAttachmentFromPDF(PDFAttachment.java:241)
         at PDFAttachmentMain.main(PDFAttachmentMain.java:21)
    Exception in thread "main"
    Note :
    PDFAttachment
    - Class
    readAttachmentFromPDF
    - method
    The code is,
    String PDFDocName = "podetailswithAttachment.pdf";
                        //wdComponentAPI.getMessageManager().reportSuccess("Outside try FileName :"+PDFDocName );
                        try
                             //wdComponentAPI.getMessageManager().reportSuccess("Inside try FileName :"+PDFDocName );
                             FileInputStream fileInpStrm = new FileInputStream("C:\"+PDFDocName);
                             FileOutputStream fileOutStrm;// = new FileOutputStream()
                             ByteArrayOutputStream bo = new ByteArrayOutputStream();
                             int c;
                             while ((c = fileInpStrm.read()) > -1)
                                  bo.write(c);
                             byte[] pdfSource = bo.toByteArray();
    // Line :240     
                             IWDPDFDocumentHandler pdfdocHandler =WDPDFDocumentFactory.getDocumentHandler();
                             IWDPDFDocumentAccessibleContext pdfdocaccContext = pdfdocHandler.getDocumentAccessibleContext();
                             pdfdocaccContext.setPDF(bo);
                             IWDPDFDocument pdfDocument = pdfdocaccContext.execute();
                             IWDPDFDocumentAttachment[] pdfatt =   pdfDocument.getAllAttachments();
                             //wdComponentAPI.getMessageManager().reportSuccess("Length of the attachments: "+pdfatt.length);
                             //pdfdocaccContext.setPDF();
                        catch(Exception e)
                             //wdComponentAPI.getMessageManager().reportSuccess(""+e);
                             System.out.println(""+e);
    Thanks,
    Prabhakar.

  • Why jdbc api ?why not use odbc api from java application?

    hi guys....am pretty confused abt these jdbc drivers...am unable to understand why we r using jdbc api when odbc api has been in market prior to jdbc.....please clarify my doubt

    chari wrote:
    hi guys....am pretty confused abt these jdbc drivers...am unable to understand why we r using jdbc api when odbc api has been in market prior to jdbc.....please clarify my doubtbecause jdbc is the way that java does it.
    use it or don't.
    C++ was in the market before java - why was java developed at all? cobol was in the market before C++ - why was C++ developed at all?
    %

  • Data Warehouse:java.lang.NoClassDefFound Error while using OWB API for Java

    I was writing code to use the OWB APIs for Java:
    I have imported the folowing files:
    oracle.owb.connection.RepositoryManager;
    oracle.owb.connection.OWBConnection;
    oracle.owb.connection.ConnectionFailureException;
    when jvm tries to get instance of Repositary Manger by the following code
    reposManager = RepositoryManager.getInstance();
    I get the following exception:
    Exception in thread main
    java.lang.NoClassDefFoundError: com/objectspace/jgl/HashMap
    I have checked my OWB and Java environment but I cant locate com/objectspace/jgl.jar file. Can some one tell me were this jar is located in so i can import it.

    Either use some criteria you develop related to one of the keys on the table or use some sort of record limiting method.
    Note the method of limiting will vary related to the database you are using. You will have to look at the documentation.
    For example I am told this will work in MySQL to get 200 records starting at record 100.
    SELECT * FROM myTable ORDER BY whatever ASC LIMIT 100,200
    Because you are running out of memroy I assume the table is large,
    I am not sure what the impact of the above will have on performance because if in the above if the order by is not based on an index at the server level all the records will be selected and sorted before the records are limited.
    I would make sure you have an appropriate index.
    If you use the advanced search over the user forums using "resultset paging" and possibility the database you are using you should be able to get some ideas.
    I hope this makes sense to you.
    rykk

  • Java.lang.NoClassDefFound Error while using OWB API for Java

    I was writing code to use the OWB APIs for Java:
    I have imported the folowing files:
    oracle.owb.connection.RepositoryManager;
    oracle.owb.connection.OWBConnection;
    oracle.owb.connection.ConnectionFailureException;
    when jvm tries to get instance of Repositary Manger by the following code
    reposManager = RepositoryManager.getInstance();
    I get the following exception:
    Exception in thread main
    java.lang.NoClassDefFoundError: com/objectspace/jgl/HashMap
    I have checked my OWB and Java environment but I cant locate com/objectspace/jgl.jar file. Can some one tell me were this jar is located in so i can import it.

    Do you have JAVA_HOME set in your environment?
    What's the result of
    env
    Make sure DBCA is calling the java under $ORACLE_HOME not from other installation.

  • How to send automated mail using Weblogic API ,,,,,, NOT Java Mail API.

    Hi All,
    I need to send an automated mail using BEA Weblogic API, can you please let me know how to accomplish this task,
    I will be heartly thankful to you,
    waiting for your response back
    naveen

    does it uses weblogic API ,, is thre any other way to do the task apart from email controls ,,,, because we are using timers and email control uses event genrators.

  • Mapping Windows API to Java - JNA

    I am trying to use JNA to implement the functions in the Win32 USB API (http://www2.hawaii.edu/~hermany/api.htm)
    I am trying to figure out how to map the following "HDEVINFO" which is defined as "typedef PVOID", which in turn is defined as typedef void* PVOID; (http://msdn2.microsoft.com/en-us/library/bb401729.aspx)
    ===================================================================================
         * From the API provided by Microsoft (http://msdn2.microsoft.com/en-us/library/ms792959.aspx)
         * HDEVINFO
         * SetupDiGetClassDevs(
         * IN LPGUID ClassGuid, OPTIONAL
         * IN PCTSTR Enumerator, OPTIONAL
         * IN HWND hwndParent, OPTIONAL
         * IN DWORD Flags
    http://www.alanmacek.com/usb/DDKFiles/setupapi.h
    typedef PVOID HDEVINFO;
    ====================================================================================
    HDEVINFO is supposed to be an array of structures for the device information set. How do I map HDEVINFO on to the Java class that mirrors the SetupDiGetClassDevs function in the API?

    Well I am using JNA (jna.jar) to make the call to the function available in the setupapi.dll. In the following code: Setupapi INSTANCE = (Setupapi) Native.loadLibrary("setupapi", Setupapi.class);*, this is what is being done. I am new to using JNA. Also, It would be great to have a resource that lists all the available functions for a Windows DLL. MSDN, of course is a good resource but it does not provide search results for a dll. One has to know the function to be called.
    public interface Setupapi extends StdCallLibrary {
          * Allocating an instance of the native library using the Native.loadLibrary(Class) method,
          * providing the native library interface
          * This instance is for convenient reuse. Alternatively, we can load the library into a
          * local variable so that it will be available for garbage collection when it goes out of scope
         Setupapi INSTANCE = (Setupapi) Native.loadLibrary("setupapi", Setupapi.class);
          * Declaring native structures to pass to  native functions.
          * To do this, create a class that extends Structure (https://jna.dev.java.net/javadoc/com/sun/jna/Structure.html)
          * and add public fields
          * (which may include arrays or nested structures).
          * Declaring methods that mirror the functions in the target library by defining Java methods with
          * the same name and argument types as the native function
          * (refer to the basic mappings (https://jna.dev.java.net/#mapping) or the
          * detailed table of type mappings (https://jna.dev.java.net/javadoc/overview-summary.html#marshalling) ).
          * From the API provided by Microsoft (http://msdn2.microsoft.com/en-us/library/ms792959.aspx)
          * HDEVINFO
          * SetupDiGetClassDevs(
          * IN LPGUID  ClassGuid,  OPTIONAL
          * IN PCTSTR  Enumerator,  OPTIONAL
          * IN HWND  hwndParent,  OPTIONAL
          * IN DWORD  Flags
          // TODO: public HDEVINFO SetupDiGetClassDevs(
    }

  • Is it possible to use iFS API within java stored procedure?

    question:
    is it possible to use the iFS API for file handling
    within a java stored procedure (which is invoced by a trigger)?
    is there an "elegant" workaround if it is not possible?
    problem:
    my java code using the iFS API works fine outside
    the java stored procedure
    but invoked via trigger as java stored procedure
    it throws following exception:
    IFS-20102: Unable to start service (IfsDefault)
    i am using:
    oracle 9.0.1
    oracle internet file system 9.0.1.1.0
    windows 2000
    thanks

    thanks for your help
    i looked through the applications developers guide
    the basics behind advanced queueing (as far as i understand) is:
    program A inserts a message into the queue - and program B gets message from the queue and processes it
    question 1:
    but what is the difference between advanced queuing and a queue i create by myself
    (simply with a database table) and let application B (which runs in a loop)
    check if the queue is filled
    or am i missing something important which makes advanced queuing more practicable for my problem?
    question 2:
    you wrote about advanced queuing support in iFS 9.0.3, but the newest version i found was iFS 9.0.2
    did you reffer to the advanced queuing mechanism in general or to a spezial queuing feature in iFS 9.0.3?
    thanks

  • Can I call Windows API in java?

    How can I?

    you can use JNI. I do not know much about it, but there are also some tools that make it simplier to you. One of the most famous is one call JIntegra.You pass to it a dll and it will generate for you the Java classes needed to access the API.

  • How can i execute Spaces API in java main class?

    Hi
    I am able to execute Spaces API through portal application. However if i try to execute it in java main class, its throwing an exception
    "SEVERE: java.io.FileNotFoundException: .\config\jps-config.xml (The system cannot find the path specified)"
    oracle.wsm.common.sdk.WSMException: WSM-00145 : Keystore location or path can not be null or empty; it must be configured through JPS configuration or policy configuration override.
    How can i set this path, so that i can execute Spaces API from java main class.
    Need this main class to configure in cron job, to schedule a task.
    Regards
    Raj

    Hi Daniel
    Currently i have implemented create functionality in my portal application using Spaces API, which is working fine. Now the requirement is, i need to implement a "Cron Job" to schedule a task, which will execute to create space(for example once in a week). Cron job will execute only the main method. So I have created java main class, in which I have used Spaces API to perform create space operation. Then it was giving exception.
    Later I understood the reason, as I am executing the Space API with a simple JSE client, its failing since a simple java program has no idea of default-keystore.jks, jps-config.xml, Security Policy. Hence i have included those details in main class. Now I am getting new error,
    SEVERE: WSM-06303 The method "registerListener" was not called with required permission "oracle.wsm.policyaccess"
    For your reference i have attached the code below, please help. How can i use Spaces API in java main method(i mean public static void main(String[] args) by giving all required information.
        public static void main(String[] args) throws InstantiationException,
                                                      GroupSpaceWSException,
                                                      SpacesException {
            Class2 class2 = new Class2();
            GroupSpaceWSContext context = new GroupSpaceWSContext();
            FactoryFinder.init(null);
            context.setEndPoint("http://10.161.226.30/webcenter/SpacesWebService");
            context.setSamlIssuerName("www.oracle.com");
            context.setRecipientKeyAlias("orakey");
            Properties systemProps = System.getProperties();
            systemProps.put("java.security.policy","oracle/wss11_saml_or_username_token_with_message_protection_client_policy");
            systemProps.put("javax.net.ssl.trustStore","C:\\Oracle\\Middleware11.1.7\\wlserver_10.3\\server\\lib\\cacerts.jks");
    systemProps.put("oracle.security.jps.config","C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\jps-config.xml");
            systemProps.put("javax.net.ssl.keyStore",C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\consumer.jks");
            systemProps.put("javax.net.ssl.keyStorePassword", "Test12");
            System.setProperties(systemProps);
            GroupSpaceWSClient groupSpaceWSClient;
            try {
                groupSpaceWSClient = new GroupSpaceWSClient(context);
                System.out.println("URL: " +
                                   groupSpaceWSClient.getWebCenterSpacesURL());
                //delete the Space
                List<String> groupSpaces = groupSpaceWSClient.getGroupSpaces(null);
                System.out.println("GroupSpaces:: " + groupSpaces.size());
            } catch (Exception e) {
    Regards
    Raj

  • JAXB as standard API for Java Mappings in XI?

    Hi there,
    Has anyone on this forum implemented Java mappings in XI using JAXB (reference implementation for XML/JAVA data bindings of SUN)?
    If Yes, can you please share any experiences?
    We're considering to use this API for Java Mappings in XI but first would like to get more background info.
    Cheers,
    Rob.

    Hi Roberto,
    Have tried implementing Java mapping using JAXB technique couple of years ago. However I was not able to test the mapping in XI/PI environment.
    <ul>
    <li>There is no in built support for JAXB from SAP XI.</li>
    <li>There is no documentation available from SAP on JAXB hence it is difficult to implement the mapping.</li>
    <li>We have to import JAXB specific jars along with the mapping code. my attempt to execute the mapping test in IR tool was unsuccessful It was running fine in standalone mode in local PC </li>
    </ul>
    [My question on SDN on same topic..|Java Mapping Using JAXB [Java Arch for XML Binding];
    Thanks and regards,
    Ananth

Maybe you are looking for

  • Need 3 pages from a report of 1 page at every run

    Hi Friends, I have developed a report which is an Invoice. Every invoice will be 1 page only. Now what i need is when ever the user will run the report, the report will give 3 pages (same page 2 & 3,i.e. copy of page 1) as a set of invoices, with the

  • Cannot view transport controls

    For some reason I am unable to view my transport control bar, when it used to be visible. I think it may be a silly problem that I just cannot seem to fix, though I've tried adjusting the screen and everything I can think to help fix the problem. I s

  • External .swf Loading?

    Hello. I am having trouble making a button load an external .swf file!!! I have a made a flash file, and in the navigation; once a Button is pressed it should load another .swf file but I can't get the Button to load another .swf despite numerous att

  • Why we need to use webutil

    Hi all why we need to use webuti? sarah Edited by: SarahSarahSarah on Sep 15, 2009 5:36 AM

  • H-Reap PreAuthentication ACL

    Hi. I have few APs working in hreap mode as local switching. I have Guest WLAN and after connection to that WLAN client must accept security regulations. The problem is that on WLC under Security->Web Auth -> Web login page  I put text saying: "Read