Invoke Java Library from Flex

I have Flex running on Tomcat with LCDS. On tomcat there is a JAR that has classes I'd like to use/interact with from Flex. In the simple LCDS examples they demonstrate having a Product.java class and a matching Product.as class, but the java library I am trying to use has many more classes and would take a long time to copy into Actionscript.
What is the best way to interact with the Java classes (I don't have a web service to use like in the LCDS example).

I only know we can use JNI to invoke native libraries
from Java and I have never used JNI to invoke Java
libraries from native applications (C/C++ programs).
I am going to look through the tutorial you
recommended.The last tutorial. I've only fiddled with it, as it was a bitch. If you don't need to use Suns JVM, I recomend using CNI & GCJ [ http://gcc.gnu.org/java/ ], as it is much neater.
Do you mean JNI is internally implemented by C++s
Runtime.exec method?Write a small Java application which invokes the lib you want, i.e. say you want to use Strings replaceAll method (simple example I know)
class Test {
pubilc static void main( String args[] ) {
  System.out.println( args[0].replaceAll( args[1], args[2] ) ) ;
}Then use c++ program to run "/path/to/java Test tast a e" .

Similar Messages

  • Invoke Java library from C/C++

    Hello everyone,
    Are there any approaches to invoke Java libraries from C/C++?
    Thanks in advance,
    George

    I only know we can use JNI to invoke native libraries
    from Java and I have never used JNI to invoke Java
    libraries from native applications (C/C++ programs).
    I am going to look through the tutorial you
    recommended.The last tutorial. I've only fiddled with it, as it was a bitch. If you don't need to use Suns JVM, I recomend using CNI & GCJ [ http://gcc.gnu.org/java/ ], as it is much neater.
    Do you mean JNI is internally implemented by C++s
    Runtime.exec method?Write a small Java application which invokes the lib you want, i.e. say you want to use Strings replaceAll method (simple example I know)
    class Test {
    pubilc static void main( String args[] ) {
      System.out.println( args[0].replaceAll( args[1], args[2] ) ) ;
    }Then use c++ program to run "/path/to/java Test tast a e" .

  • Invoking java methods from C/C++ on the machine with different JREs

    I implemented Windows NT Service instantiating JVM and invoking several java methods. Everything works but I have an issue with running the service on the machine where multiple different versions of JRE have been installed. The service is calling java methods that require JRE 1.3 or later so I wrote the code that is setting system PATH from within the service based on the configuration stored in the external file. The problem is that the service requires jvm.dll to be in the PATH prior lunching it since this library is instantiated through the implicit linking. When I put jvm.dll in the same path as the service binary I can lunch it but JNI_CreateJavaVM fails and returns -1. This happens even if JRE 1.3 is in the system PATH prior lunching the service.
    Everything works if the system PATH contains references to JRE 1.3 and jvm.dll is removed from the service's directory.
    I am looking for an advice on what is the proper way to deal with invoking java methods from the C/C++ executable in the environment with different versions of JRE.
    Thanks, Kris.

    Here's a way I have done what you are asking about:
    What you want to do is make all of your linking happen at runtime, rather than at compile time. This way, you can edit the PATH variable before the jvm.dll gets loaded.
    Following is some code that I used to handle a dll of my own in this manner. You can decide if you want to write a "wrapper" dll, or if you find it simpler to approach the jvm.dll in this way.
    // Define pointer type for DLL entry point.
         typedef void JREPDLL_API (*EXECUTEREQUEST)(char*, Arguments&);
    // Set up path, load dll, and pass everything off to it.
    HINSTANCE javaServer = javaServer = LoadLibrary("jrepdll.dll");
    if (javaServer != NULL) {
    EXECUTEREQUEST executeRequest = (EXECUTEREQUEST)GetProcAddress(javaServer, "ExecuteRequest");
    if (executeRequest != NULL) {
    if (argc == 1)
         // Execute the request.
         executeRequest("-run", args);
    else
         // Execute the request.
         executeRequest("-console", args);
    Here's some code for how to edit the PATH:
              // Edit the PATH environment variable so that we use our private java.
    char *appendPt;
    char *newPath;
    char *path;
              char tmp[_MAX_PATH];
              // Get the current PATH variable setting.
    path = getenv("PATH");
              // Allocate space for an edited path setting.
              if (path != NULL)
                   newPath = (char*)malloc((_MAX_PATH * 2) + strlen(path));
              else
                   newPath = (char*)malloc((_MAX_PATH * 2));
              // Get upper part of path to desired directories.
              strcpy(tmp, filepath);
              appendPt = strstr(tmp, "dbin\\jreplicator");
              appendPt[0] = '\0';
    sprintf(newPath, "PATH=%sjava\\jre1.2.2\\bin;%sjava\\jre1.2.2\\bin\\classic", tmp, tmp);
    // Append the value of the existing PATH environment variable.
    // If there is anything, append it.
    if (path != NULL) {
         strcat(newPath, ";");
         strncat(newPath, path, (sizeof(newPath) - strlen(newPath) - 2));
    // Set new PATH value.
    _putenv(newPath);
              free(newPath);

  • Finally i found a way to invoke a .exe from flex

    hi
    Months before i had posted a question in the forum about
    invoking a .exe from FLEX...
    now after trying out many things from LCDS to java...I
    finally found a way to do it....
    I ve put up the link here...
    Flex
    Solution

    google
    setup msn mail as pop3 on iphone
    google
    setup gmail as pop3 on iphone
    the way is the same if it's iphone or ipad

  • How to invoke java application from ABAP

    How to invoke java application from ABAP  ? Suppose I needto execute a EJB wihic is running on my SAP J2EE Enigne from an ABAP Program .
    Thanks,
    Manish

    Hi Manish,
    did you get some further documents concerning "abap program calls ejb"?
    If yes, could you please send me some informations.
    Thank you for your help.
    Kind regards, Patrick.

  • Error Invoking Java class from Stored proc

    We are getting this error while calling a stored procedure that invokes a
    static function of a java class from inside Oracle 8.1.7.
    ORA-29516: Aurora assertion failure: Java thread deadlock detected
    ORA-06512: at "APPS.SERVICECONSUMERINVOKE", line 0
    ORA-06512: at line 40
    In a Toad SQL Window, when I execute the stored procedure that invokes the
    java function, it executes successfully on the first attempt. When I try to
    execute it again on the same SQL Window, it gives the above error. The java
    class is part of a package and indirectly makes a JMS request-reply call
    via other helper classes.
    The same package works fine from other web containers and
    unlike the Oracle JVM Aurora, the JVMs don't detect a deadlock.
    Why does the Aurora throw an error?

    Did you try issusing a commit and then trying again in Toad SQL Window?
    The advice is to contact support:
    ORA-29516: Aurora assertion failure: string
    Cause: An internal error occurred in the Aurora module.
    Action: Contact Oracle Worldwide Support.

  • Invoke Java 3d from a JSP?

    Hi,
    I have a sample java code that invokes a Canvas3d and then invokes a 3D object.
    Our project goal is to create an online application-- A JSP page which will invoke the java 3d object.
    I am working on Oracle JDeveloper and OC4J server.
    Currently , the application runs thru a .java file.
    I want to know if it is technically possible to create a jsp page and transfer the 3d object generated by this java file onto the JSP?
    I tried renaming the main method of the java file to say testMain (made it static method).
    Then thru the JSP , i tried to call this testMain method.
    It doesnt work.
    thanks

    HI
    I was able to add a canvas3D to a webbrowser via an applet. I suppose you can always invoke an applet from a JSP.
    Venkat

  • How to invoke Java class from post.POST.jsp

    Hi All,
    I am trying to invoke a simple java method from post.POST.jsp
    I am getting below exception while doing it.
    org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 32 in the jsp file: /apps/mywebsite/components/customFormAction/post.POST.jsp
    The method test() is undefined for the type DatasourceUtil
    29:          
    30:           ///
    31:          com.day.test.datasource.DatasourceUtil dsUtil = new com.day.test.datasource.DatasourceUtilImpl();
    32:          dsUtil.test();
    33:           //dsUtil.validateLogin(request.getParameter("username"), request.getParameter("password"));
    34:          
    35:           ////
    It appears to resolve the class correctly. I could run the code, if I only comment  dsUtil.test();. As soon as I uncomment, it gives above error.
    In the Utill I have a simple void method which will print a simple text. My package structure is as follows.
    any help will be great
    Tx

    1.  In the interface [1] not the implementation[2] have u defined the method test?
    2.  If it is implemented, Change the bundle version in bnd file and make a new build. Then from felix console verify the latest version reflected in the bundles.
    If 2 works & you are going to make lot of frequent changes then give the version as snapshot till it get stable.
    [1]  com.day.test.datasource.DatasourceUtil
    [2]   com.day.test.datasource.DatasourceUtilImpl

  • Problems to invoke java.exe from Java application, but ok for javac.exe??

    How to invoke DOS application from Java application??
    I try the following but it didn't work to invoke command prompt and java.exe, it
    is working to invoke javac.exe. Any ideas why??
    import java.io.*;
    public class CallJavaTest
    { public static void main(String[] args)
    { try
    Runtime.getRuntime().exec("C:\\WINNT\\System32\\cmd.exe"); //doesn't work!!
    Runtime.getRuntime().exec("javac "+ "Test.java"); //it works!!
    Runtime.getRuntime().exec("java "+ "Test"); //doesn't work!!
    catch(IOException e)
    System.out.println(e);

    hi
    String[] cmd = {"cmd","/c", "start",enteryourdoscommandhere};
    Runtime rt = Runtime.getRuntime();
    Process ps = rt.exec(cmd);
    ps.waitFor();
    int ev = ps.exitValue();
    it works for my winXP.
    hope it can helps and not too late ..

  • How to read static variable defined java class from flex?

    This is a beginner question. If I use remoteClass to map a java class and a flex class, how can I access a static variable defined in java class from the flex code?
    Thanks!

    Static propeties are by default ignored in the blazeds for serialization. You can try using another global property in the java bean which maps to the value stored in the static property( Hopefully it should work)
    eg,
    public String instanceValue = ClassName.staticValue;
    Ref: http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=serialize_data_3.ht ml

  • Invoking java exe from C++ code

    Most of my applications are in c++, i have one application in java.
    How can I invoke the java application(jar) from c++ code?

    Hi We can do this by using EXTERN C functionality provided by c++ ,
    by using this we can call the Java functions from Java .class file.
    or .jar file.
    (for java developers ......its similer to JNI)
    if you want more details aboth such code just search it on web , you will get number of programs here.
    Thanks,
    -Akshay

  • Invoking Java Applet from SAP Netweaver Eportal using java webdynpro

    Hi ,
    We are using SAP Netweaver portal version 7.0.WE want to invoke java applet into webdynpro java application on button click.
    The Applet should open in a new window when the particular parameter is selected and the button is clicked
    The code is given below:
    String html = "<HTML> <HEAD></HEAD> <BODY><APPLET code=\"org.faceless.pdf2.viewer2.PDFViewerApplet\" type=\"application/x-java-applet;version=1.4.2_05\" archive=\"bfopdf.jar\" width=800 height=600></APPLET></BODY></HTML>";
    IWDCachedWebResource resource = WDWebResource.getWebResource(html.getBytes("UTF-8"), WDWebResourceType.HTML);
    resource.setResourceName("HTML_inline.html");
    IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getAbsoluteURL(),"Image");
    window.removeWindowFeature(WDWindowFeature.TOOL_BAR);
    window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
    window.removeWindowFeature(WDWindowFeature.STATUS_BAR);
    window.open();
    But after clicking on button new html window is opening and the applet is not showing properly. The java console showing the error:
    java.lang.ClassFormatError: Truncated class file
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClassCond(Unknown Source)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassFormatError: Truncated class file
    Please suggest how to solve this error.
    Regards,
    Dhruba

    Hi,
    I'm not sure, but I believe the 'code' argument should end with '.class'. However, your implementation of displaying a Java applet seems ok, the error is within the applet's Jar file
    Anyway, have a look at http://download.oracle.com/javase/1,5.0/docs/guide/plugin/developer_guide/using_tags.html#applet and http://www.w3.org/TR/html401/struct/objects.html#h-13.4 on how to use the <applet> tag
    As a test, you could try and create a local HTML document on your local desktop, including the applet. I would suspect you will receive the same error in your Java console
    I believe the only option is to recompile your Java applet (if possible at all) against a newer JDK (1.4 and up)

  • No Class Found Error on invoking java class from PL/SQL

    Hi There,
    I have followed instructions on how to create a java proc in the DB to invoke it from PL/SQL.
    I get a 'java.lang.NoClassDefFoundError' error because it cannot access 'org.apache.axis.description.TypeDesc' in this case. The instuctions say to add the supporting jars which contain the additional classes to the project's Additional Classpath's which I have done.
    I deploy the java classes and create the java stored proc using JDev.
    Can someone please tell me how to go about resolving this?
    I can see 'org.apache.axis.description.TypeDesc' in the DB via JDev's Databse connection in the Java Classes tree?
    Thanks,
    Anthony

    Hi There,
    I have followed instructions on how to create a java proc in the DB to invoke it from PL/SQL.
    I get a 'java.lang.NoClassDefFoundError' error because it cannot access 'org.apache.axis.description.TypeDesc' in this case. The instuctions say to add the supporting jars which contain the additional classes to the project's Additional Classpath's which I have done.
    I deploy the java classes and create the java stored proc using JDev.
    Can someone please tell me how to go about resolving this?
    I can see 'org.apache.axis.description.TypeDesc' in the DB via JDev's Databse connection in the Java Classes tree?
    Thanks,
    Anthony

  • Invoke Java method from C++

    hello, I hope you can help me.
    In the moment I am trying to use Global Hotkeys.
    I am able to register global Hotkeys from Java in C++. My problem: I can't invoke an other java method as result of pressing my hotkey.
    void OnHotKey(void *)
         printf("invoke my java method");
    so I want to do a backcall to java in a c++ method. At Beginning Java registers my global Hotkeys in an c++ native method.

    (My JNI is rusty, and the tutorial is gone),
    Something like (Pusdo code, see JNI Spec: Accessing Fields and Methods ):
            JNIEnv * g_env, jobject g_obj;
         void OnHotKey(void *)
              // cut from the example posted above
              jclass cls;
              jmethodID mid;
              cls = (*env)->FindClass(env,"my.Class");
              if( cls == NULL ) {
                        return;
              mid=(*env)->GetMethodID(env, cls, "onHotKey", "()V");
              (*env)->CallVoidMethod( obj, mid );
         CHotkeyHandler hk;
         JNIEXPORT void JNICALL Java_gui_Gui_activateGlobalHotkeys
         (JNIEnv * env, jobject obj) {
              int err, id;
                 hk.RemoveHandler(id = 0);
              hk.InsertHandler(MOD_CONTROL | MOD_ALT, 'A', OnHotKey, id);
              // We need this in OnHotKey
              g_env = env;
              g_obj = obj;
              err = hk.Start("calc.exe");
              if (err != CHotkeyHandler::hkheOk)
                   printf("Error %d on Start()\n", err);
         JNIEXPORT void JNICALL Java_gui_Gui_deactivateGlobalHotkeys
         (JNIEnv * env, jobject obj) {
              int err = hk.Stop();
    }

  • Calling java library from cocoa?

    Hi,
    I'm looking at developing an application that interacts with Google's APIs for Gdata. Google has client libraries in Java but with all the issues (and death) of Cocoa-java is my only reasonable option to code the whole thing in Java?
    Thanks,
    Andy

    Hi Andy
    Each separate iCal calendar is held in a separate folder, with names like EF43A64B-C7B4-4F97-BA46-F722C29709DF.calendar and F882741C-F941-4C08-BD3A-81268842F4BC.calendar
    Within each folder is a corestorage.ics file (the calendar file), an Info.plist file and an Index file. To find the name of the calendar within any folder you read successive lines of text from Info.plist until you find this line:
    <key>Title</key>
    The calendar name is contained on the next line, eg:
    <string>Work</string>
    Do a search on this line for ">" and "</" command, then the saved file is actually a folder in exactly the same format as that stored in the user library, so you can use the same code to read it.
    Bob

Maybe you are looking for

  • Unable to Deploy Par  File in the Portal

    Hi Experts, When i'm trying to deploy the par file to the portal after Configuring the server settings it's giving me an error. "Operation Failed: Please make sure the server 'DEV' (hostname:port) is running or check the log (sap-plugin.log) for more

  • How do I sort by Album and not Artist on my 7th Generation

    I can't veiw my music on my ipod nano by just album. It's separated everything by artist and doesn't just play the whole album. How do I fix that?

  • Help changing registered name

    My cousin gave me his iPod nano as a gift, when i connect my iPod to my PC and open iTunes i see my cousin's name, now i would like to know how to change it so my name shows instead of my cousin's. Thanks. PC   Windows XP Pro  

  • Logging JDBC info to log files...

    BlankGuys , Im using -Dweblogic.ejb20.cmp.rdbms.verbose=true" "-Dweblogic.ejb20.cmp.rdbms.debug=true while starting my server... all debug info goes to console. I want it to be logged on to a file. So I see all info from RDBMSPersistenceManager on co

  • Burned Dvd frezes

    please help me! I have a problem burning my project into a dvd disc on adobe premiere elements 12.. when i tried to watch it on a dvd player my burned dvd frezes and im unable to watch my movie the way i  want it. what can i do?