Make native code and Java VM interact

Hi all,
I am building a native components (Delphi and C++) using JNI.
Currently my components involve a Java GUI.
It loads the JVM, then request for that Java Object GUI.
When the interface is created, I need to get back information
from what the user can type in.
However, the native code doesn't wait. It runs and continues right after
the creation of the GUI, thus causing me trouble (trying to get
null objects).
Is there a way to make the native code wait for a java command from
the interface, or is there a way to make both part of the component
(java / native) to communicate and interact ?
Any help would be appreciated.
Thanks
Regards,
Florent

There are quite a few options here, and this may not
be the best, per se, but you could make a blocking
call from the JNI to a Java method. That Java method
will only return after whatever you want done in the
interface has completed.Thanks for your reply. Is there other solution in the JNI itself,
using the JNIEnv Object ?
Else, I'll try to use that solution.
Regards,
Florent

Similar Messages

  • How to run 64-bit native code with Java Web Start

    This question has probably been asked many times, but I couldn't find anything in my searches.
    How can I get Java Web Start on a Solaris client (Solaris 10 in this case, with JRE 1.5) to run a java application that includes a 64-bit native code library? The application downloads fine, including the jar file that has the native shared object, but when the native library is loaded by the java application, I get a "wrong ELF class: ELFCLASS64" error.
    I assume that is because Web Start is invoking the 32-bit java VM, which can't load a 64-bit library. I tried configuring Java Web Start to use the 64-bit VM (by setting the path to java to ".../jre/bin/sparcv9/java" in the javaws console) but then I get an error that says "Can't load library: .../jre/lib/sparcv9/libdeploy.so".
    Does Java Web Start support 64-bit native code, and if so, what do I need to do differently?
    Thanks.

    No it can't. On the Sun download page of the JRE it says that 64 Bit systems need to use the 32 Bit JRE to execute Plugins - this might be the same for Web Start apps.

  • Profile native code that JAVA application runs

    our application is suffers from a severe memory leak. the application runs on Weblogic that uses the severe container and access Oracle DB.
    the JAVA heap was monitored for several weeks (using the verbose gc flag) and no leak was discovered. we monitored the native heap (by using the pmap command) and we saw that the heap size increasing. therefor we think the problem is in the native code that runs in this process (the major suspect is the OCI, Oracle client).
    after reading the man page of collect and your Article (Profiling Java Appl with Sun Studio 11) I'm confused. I would like to monitor the native heap (with -H option) but in the man page it's written that "Heap profiling is not supported for java programs" so i wheni set the flag -j off i got a warning that this process is java and i might use the -j on.
    please advice what are the values of the flags -j an -H in case of i need to monitor the native code of java application.
    thanks
    yahav

    thanks again for the additional article about the Weblogic.
    in the startManaged script I added the following prefix:
    collect -H on -j off -d /tmp/ java...
    when i typed leaks on er_print, i got a list of possible leaks and allocs.
    some activities were made on the application so i assume that data should be collected. as the size of the experiment folder slightly increased.
    so far we can assume that the data that is relegated to the non java process was collected.
    when i typed leaks again within the er_print tool i got the same results.
    it means that no native heap activities was made.
    is it correct analysis?
    regards the leak that was discovered above, how one can identify the function that cause this leak. i can see calls like:
    malloc, ReadKnownVMs, CreateExecutionEnvironment. this functions relate to the JVM. i would expect to see some trace (allocs) regards the other native code that runs such as the Oracle OCI client.
    I'm suspecting i'm collecting this info.
    is there any other flags to set for such collection? or any other commands in the analysis command

  • How can i merge javafx code and java fxml code in a single project

    how can i merge javafx code and java fxml code in a single project.
    Please let me Know as soon as possible.

    Everything that it is possible to retrieve from a class file can be deduced from the class file definition.
    http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html
    Sylvia.

  • Page Flow and Java Control interaction

    Hi everybody !
    Even after to read some documents like
    http://dev2dev.bea.com/pub/a/2004/06/wlw_internals.html
    and
    http://dev2dev.bea.com/pub/a/2004/01/jones.html
    i still didn't get what is really happening "behind the scenes" between Page Flows and Java Controls (Workshop 8.1). I would be glad if anyone could send to me more detailed documentation or explanation about this subject.
    How can a Java Control to stand behind a Stateless Session Bean (GenericStatelessSLSB) and still to keep its internal state (instance variables) consistent ? How can a statefull Java Control to remain statefull being accessed by a stateless component (the EJB) ? Or is the source code of a Java Control (the JCS file) kept by the Page Flow and sent to EJB for its execution ?
    Thanks in advance.

    Hi Daniel
    I have attached a doc I created that explains what happens behind the scenes
    when a pageflow call a JCS va a JWS calling a JCS.
    Can you please go through the document and let me know any questions you may
    have?
    Thanks
    Vimala
    <Daniel Lima> wrote in message news:[email protected]..
    Hi everybody !
    Even after to read some documents like
    http://dev2dev.bea.com/pub/a/2004/06/wlw_internals.html
    and
    http://dev2dev.bea.com/pub/a/2004/01/jones.html
    i still didn't get what is really happening "behind the scenes" between
    Page Flows and Java Controls (Workshop 8.1). I would be glad if anyone
    could send to me more detailed documentation or explanation about this
    subject.
    How can a Java Control to stand behind a Stateless Session Bean
    (GenericStatelessSLSB) and still to keep its internal state (instance
    variables) consistent ? How can a statefull Java Control to remain
    statefull being accessed by a stateless component (the EJB) ? Or is the
    source code of a Java Control (the JCS file) kept by the Page Flow and
    sent to EJB for its execution ?
    Thanks in advance.

  • Hex code and java

    Hi to everyone!
    I must write a java application that converts files from html to xml using jtidy package(particularly,using the parse method).But after this conversion the hex code 0D0A appears in the xml files;
    so,for example,the sentence(in the html file):
    Login or Password is incorrect
    becomes(in the xml file):
    Login or Password is
    incorrect
    How can I do to have the whole sentence on the same line,even in the xml file?I need to have this change in the string because I've to do xpath queries on it,and java doesn't recognize hex code.Could I apply any jtidy setting?If yes,which one??Otherwise..how could I solve my problem?
    Please,help me!!!

    Yes, but your question isn't clear to me. Where are these 5 values coming from? Do you have an array with 5 values? To convert an int to a hex String, use Integer.toHexString(yourInt);

  • How can I view native code in Java?

    I am trying to write a program to find the log of a number. I looked for Java's implementation in Math.log(x), but it is a native method. How can I see the code in the other language(C or C++)? I have looked at JNI, but i don't think it is what i need. Any Ideas??

    Before the Mustang release, i don't believe sun
    released the source code to the native binaries.Actually, I'm pretty sure they did, but I don't know off the top of my head where to get it. You'd have to search.

  • Forms 10g R2 and Java Bean Interaction

    Hi,
    I need some help.
    I have a Forms app and a Java app that i need to communicate between them.
    The Java app send and receive events. How i send and receive events in Forms 10g.
    What you recommend to do that.
    Thank You. JP.

    There is a very good example in the otn in the forms-demo-section.
    Go: OTN - Sample Code - Oracle Forms - JavaBeans
    try it
    Gerd

  • Instantiating a Java class in native code.

    I'm trying to figure out how to instantiate a Java class in native code (C/C++) but no luck so far.
    Given a class called DataPacket written in Java, how can I create in the native side of the code?
    Any ideas?
    Thanks.

    chickenlips wrote:
    Hi NiceGuy,
    Thanks for responding. Yes MyClass.class is in the right place.
    A call to env->ExceptionDescribe(); reveals that it can't find org\apache\commons\logging\LogFactory
    Apparently, when I specified:
    options[0].optionString = "-Djava.class.path=c:\My Workspace\JNITest"
    vm_args.options = options;
    It does not append to my classpath environment variable, but instead overwrites it.
    My solution was to list out every jar files I was using and append them to the optionString. Is there a better way to do it?
    A new question: Is there a way to append to the CLASSPATH environment variable using the java.class.path? Or should/could I have use the classpath option instead of the -D option?The 'classpath' option won't be recognized by the Invocation API. To append to the CLASSPATH environment variable, you call call getenv("CLASSPATH") in your native code and use strncat() to concatenate it with your option string.

  • Not returning from the native code

    Hi,
    I am trying to access the native code using java applet. My java code seems to load the DLL(created using the VC++ 6.0) properly. Then when i call the native method called crypto, it does not seem to return from the nayive code . I am signing the applet and putting it a signed jar .Any suggestion is appreciated. I mite be wrong in the design too ...pleas ehelp. I am pasting the java code and the C code.
    cryptoJNI.java
    import java.awt.*;
    import java.io.*;
    import java.lang.*;
    import java.applet.*;
    public class cryptoJNI extends Applet {
         String uname=null;
         String b=null,ret=null;
         String a=null;
    public void init(){
              System.out.println("in init");
         public void dll_load(){
              b="before dll";
              System.loadLibrary("Msgimpl");
              a="after dll load";
         private native String crypto(String store);
    public void paint(Graphics g) {
              g.setColor(Color.blue);
              g.setColor(Color.magenta);
              load_dll();
              g.drawString(b, 5, 5);
              g.drawString(a, 15, 15);
              g.drawString("first call const", 25, 25);
              cryptoJNI app = new cryptoJNI();
              ret=app.crypto("My");
    g.drawString(ret, 75, 75);
              g.drawString("Signed 11", 120, 80);
              stop();
    CryptoJNI.c
    #define WIN32WINNT 0x0400
    #include <windows.h>
    #include <jni.h>
    #include <wincrypt.h>
    #define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
    #include "cryptoJNI.h"
    BOOL APIENTRY DllMain(HANDLE hModule,
    DWORD dwReason, void** lpReserved) {
    return TRUE;
    JNIEXPORT void JNICALL
    Java_CryptoJNI_crypto(JNIEnv * jEnv,jobject obj,jstring jstore) {
    //     char               name[256];
         const char *msg;
         msg = (*jEnv)->GetStringUTFChars(jEnv, jstore,0);
         //printf("Before context\n");
         //(*jEnv)->ReleaseStringUTFChars(jEnv, jstore,msg);
         return (*jEnv)->NewStringUTF(jEnv, msg);
    In my applet, i have some debugging statements that helps me verify that the Msgimpl.dll loads properly. When i invoke the app.crypto() it just "hangs". Please help
    Thanks,
    Vivek

    Hi,
    This is the exception that i am getting?? my cryptoJNIImp.c is is in the same directory as the my java file,c:\vivek work\signedcode. and i have added this to my path env variable...If u see the output, it executes the init() and then loads the Msgimpl.dll. So its got nothing do with loading a DLL. Any pointers on this..
    in init
    before loading dll
    After loading dll
    java.lang.UnsatisfiedLinkError: crypto
    at cryptoJNI.crypto(Native Method)
    at cryptoJNI.paint(cryptoJNI.java:65)
    at sun.awt.RepaintArea.paint(Unknown Source)
    at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

  • Native code (c++ exe)  for detecting jre version

    hi,
    we have got a cd to be sent to customers. if no java enviroment is present or , jre vversion is below 1.5 we must force user to setup jre 1.5.
    our setup must begins with a c++ exe( while there could be no java enviroment on machine). how do we understand which version or not he is using.
    could there be a small utility or something like thar? or could we find sources with c++ for this topic.

    i taught a trick infact, could it be i write some java code
    System.getProperty("java.vm.version");
    convert it in a native code and get it, is it to nonsense

  • Vendor code and vendor name in ME5A

    Dear Experts,
    In T.code ME5A Vendor and name of Vendor fields display in output but it is showing blank whenever po is created how can I found that which PR,s Po make vendor code and name display.
    RC

    Hi,
    Using T-code ME5A report vendor,name of vendor if required,
    you will create using T-code ME01-Maintain source list input data's are Material,Plant,Vendor,pur.org.,valid from,valid to and fixed source field tick, to be given and SAVE.
    After that you will see ME5A report. vendor,name of vendor data's are display.
    Hope, it is useful for you and resolve the issue.
    Regards,
    K.Rajendran.

  • What's the difference between using java directly in JSP and java bean

    What is the difference if I use java code directly in JSP or use java bean in JSP?
    Which class to use for receiving the passed parameter from html or java script? Any difference for java code and java bean in the way receiving the passed data?
    How can I pass string from jsp to html or java script?

    1 Cleaner pages
    2 you have to write the class and use set and get methods
    3 What do you mean when saying passing string from jsp to html??, do you mean the value you can use <%=variablename%>

  • Does JVM variable java.library.path make sense from native code?

    Hello all,
    Well, everybody loads native library from the Java side by calling System.loadLibrary("myNative").
    But what if, for example, myNative.dll loads another two libraries itself?
    Suppose, when I call java method "initMyNative", it in turn call native function Java_initMyNative(...). That Java_initMyNative(...) wants to load two native libraries and make: HINSTANCE lib01 = LoadLibrary("auxlib01.dll");  // LoadLibrary from capital, it's Win function!
    HINSTANCE lib02 = LoadLibrary("auxlib02.dll");  // LoadLibrary from capital, it's Win function!As specified, native LoadLibrary call will look for auxlib01.dll and auxlib02.dll in catalogs which are enumerated in system variable PATH, current catalog.
    Does java.library.path make any sense on order of such search?
    If not, is there any way of flexible configuring of the catalog in which to look auxlib01.dll and auxlib02.dll for?
    I see some ways:
    * changing system variable PATH - not flexible
    * passing content of java.library.path into native code, parsing it and looking for auxlib01.dll and auxlib02.dll in each catalog listed in java.library.path - too heavy
    I hope there is more smart way to do that.
    Thanks, Alex

    Thank you Shane for your reply. I actually didnt have to create 2 jar files, one for Java files and one for the dll file. I got an idea from your post and referenced the same jar file twice by saying:
    <j2se version="1.2+" />
    <jar href="HelloWorld.jar"/>
    <nativelib href="HelloWorld.jar"></nativelib>
    and by saying that the jnlp file started working from the browser.
    Again, thanks a lot for your replies.
    Thanks
    Nick

  • Java code and jsp interaction

    Hi,
    How does one interact between java code and jsp page.That is, if the java code does say database connection, the web page should tell that the connection has been made,just like an application but this will work on the web server not in the console.Kindly let me know.
    As

    Just curious but where do these questions come from? A course you are taking or you are building something for a hobby?
    If you are building some small simple web-app it's probably quicker to embed code right onto your JSP page.
    There are various levels of abstracting your web-app separating display from logic from the model.
    The following are techniques from simple web-apps to more complicated ones.
    -Embedding script right into your JSP
    -Using beans
    -Using custom tags ( I think there are some standard ones now, struts seems to be a popular buzzword)
    -Including a servlet to handle your requests redirect, update bean content grab info form your database and forward to a JSP. (Read up on model 2 architecture.)
    To include as much detail as possible would be to write a book. Fortunately many have so I don't have to fit one in this tiny reply box.
    Hope that was somewhat useful.

Maybe you are looking for

  • How do i stop my macbook pro from stuttering?

    my mac started behaving very strangely this week. in all computer operations, there is a visual stutter that happens roughly every ten seconds. this is most obviously displayed in watching a youtube video. another example is, if i open TextEdit and h

  • GR amount is not matching with PO unit price

    Hi folks, I have created a Purchase Ordre in foreign currency euro with account assignment project. Say the unit price of the item is euro 500/pc. While doing GR for three pcs, it is showing in purchase order history only 9 euros and in local currenc

  • Example of Xlet ( java TV )

    Somebody have one example of Xlet ( java tv ). Nothing very difficult, but if this is difficult, it`s ok. Thanks, Gpleite

  • Mm/dd/yyyy??

    Hi, Sorry for my noob question. But how do you convert a mm/dd/yyyy date format to yyyymmdd . So I can insert it to a table

  • How to program chapter returns

    How can I program chapters to return to the menu and also have a play all?