Accessing Java Strings from C

I use this as the docs say, to convert:
JNIEXPORT jstring JNICALL
Java_SpeedProcess_exec(JNIEnv *env, jobject obj, jstring prompt)
char buf[128];
const char str = (env)->GetStringUTFChars(env, prompt, 0);
printf("%s", str);
(*env)->ReleaseStringUTFChars(env, prompt, str);
but when I try to compile, I get:
Compiling...
HelloWorldImp.cpp
c:\java\NativeCode\HelloWorldImp.cpp(13) : error C2819: type 'JNIEnv_' does not have an overloaded member 'operator ->'
c:\Program Files\j2sdk_nb\j2sdk1.4.2\include\jni.h(750) : see declaration of 'JNIEnv_'
did you intend to use '.' instead?
c:\java\NativeCode\HelloWorldImp.cpp(13) : error C2227: left of '->GetStringUTFChars' must point to class/struct/union
type is 'JNIEnv'
did you intend to use '.' instead?
c:\java\NativeCode\HelloWorldImp.cpp(15) : error C2819: type 'JNIEnv_' does not have an overloaded member 'operator ->'
c:\Program Files\j2sdk_nb\j2sdk1.4.2\include\jni.h(750) : see declaration of 'JNIEnv_'
did you intend to use '.' instead?
c:\java\NativeCode\HelloWorldImp.cpp(15) : error C2227: left of '->ReleaseStringUTFChars' must point to class/struct/union
type is 'JNIEnv'
did you intend to use '.' instead?
c:\java\NativeCode\HelloWorldImp.cpp(50) : error C2561: 'Java_SpeedProcess_exec' : function must return a value
c:\java\NativeCode\HelloWorldImp.cpp(9) : see declaration of 'Java_SpeedProcess_exec'
Build log was saved at "file://c:\java\NativeCode\Debug\BuildLog.htm"
NativeCode - 5 error(s), 0 warning(s)
Anyone?

I solved it, thanks

Similar Messages

  • (how) can I access Java APIs from web-page-hosted JavaScript?

    Can I access Java APIs from a web-page via JavaScript if I have a JRE installed on the client machine? And if so, how?
    Thanks in advance for your time and consideration.

    John L. wrote:
    Can I access Java APIs from a web-page via JavaScript if I have a JRE installed on the client machine? And if so, how?As far as I can remember that was actually possible in the very first versions of Netscape because Netscape really wanted to pretend Javascript and Java were meant to be used together. But they soon removed that functionality. Can you guess why?
    Because people were using the File/IO classes to easily steal or remove files on the harddrive, among other such niceties. You do NOT want to have such control from a web application. People will abuse it.

  • Accessing java objects from within javascript

    Hello,
    Anyone with an idea of a useful toolkit for accessing java objects from within javascript will be much appreciated.
    Thanks in advance,
    Antana.

    What do you mean by accessing Java objects? Do you mean interacting with an applet via JavaScript? Something else?

  • Accessing java classes from javascript

    Hi,
    I have the following javascript function
    function testjava {   
        var myString = new java.lang.String("Hello world"); // line 1
        alert("len:"+myString.length()); // line 2
    }It gives me a error at line 1 saying "'java' is undefined" in IE browser 5.5 sp2. But, both the lines execute correctly in netscape 6.
    Can someone please help..
    Thanks,
    Vijay.

    It seems that IE 5.5 doesn't support accessing java classes in JavaScript, so try to install IE 6 to see if it works or maybe, you doesn't have installed propertly support for JVM in IE.

  • Accessing Java Classes from Forms

    Is is possible to access a Java class from Forms? I have been
    creating an Active X control that returns a Java object, and from
    that I can call methods on that object, but I would really like
    to do that without having and Active X control in the mix. Any
    suggestions?
    null

    Oracle Developer Team wrote:
    : Robert Nocera (guest) wrote:
    : : Oracle Developer Team wrote:
    : : : hey robert -
    : : : Developer 6.0 provides this ability for web deployment.
    You
    : : can
    : : : insert your own custom Java components into your
    application
    : : and
    : : : they will appear in the application when it is run via the
    : web.
    : : : If you look at the documentation for 6.0, there are a few
    : : : section son Pluggable Java Components and JavaBeans that
    : : : describes what is provided and how you use the interfaces
    : and
    : : : classes we provide.
    : : : A whitepaper on this topic will be posted to the OTN
    : shortly,
    : : as
    : : : well as some samples that illustrate how to go about doing
    : it.
    : : : cheers!
    : : : -Oracle Developer Team-
    : : Thanks for the quick response. Is there any way to access
    : those
    : : classes without being in a web deployment. That's probably
    : not
    : : totally out of the question, but what we had in mind was
    : adding
    : : some Java Functionality (actually connectictivity to some
    EJBs
    : : that we have) to existing forms. Currently there forms are
    : not
    : : deployed in a "web" environment and are just run from the
    : forms
    : : runtime engine.
    : : -Rob
    : hey again robert -
    : there's no easy way (yet!) to call out from forms runtime
    : process to a Java application.
    : We've played around some with creating an ORA_FFI interface to
    : JNI and then wrappering this with PL/SQL code. We've been able
    : to make calling into an EJB running in 8i from a forms runtime
    : work using this approach.
    : Let me know if this is of interest to you and I can post the
    : stuff we've currently got. It's no more than a simple demo and
    : is not complete. It requires quite a bit of manual coding on
    : the PL/SQL side since the interface emulates JNI (FindClass,
    : GetMethodID, CallMethodID, etc.).
    : cheers!
    : -the Oracle Developer Team-
    I'd be interested in this ORA_FFI doc you've been playing with.
    Would you please email it to me or post it.
    null

  • WPC: Access Java beans from XSL

    Hi,
    How can we access custom Java beans from within the XSLs used to render WPC webforms? Do we have to implement a custom XSLT Helper? I am able to access standard Java classes using the <xmlns> tag but when I try to reference our custom classes the WPC editor throws a ClassNotFound exception. Any help will be appreciated.
    Thanks and Regards,
    Shibendra

    Hi,
    How can we access custom Java beans from within the XSLs used to render WPC webforms? Do we have to implement a custom XSLT Helper? I am able to access standard Java classes using the <xmlns> tag but when I try to reference our custom classes the WPC editor throws a ClassNotFound exception. Any help will be appreciated.
    Thanks and Regards,
    Shibendra

  • How to copy/access a string from inside the driver

    is there any equivalent to strncpy() to use inside
    the driver for copying user sent data to local buffer .
    i used I_STRioctl and assigned struct to strioctl.ic_dp
    as shown below..
    char * buf;
    struct user-data
    int minor;
    char* data;
    struct user_data u_data;
    buf="hello world"
    u_data.minor=0;
    u_data.data=buf;
    strioctl.ic_dp=&u_data;
    strioctl.ic_len=sizeof(struct user_data);
    ioctl(fd,I_STR,&strioctl);
    when i tried to copy/access the string sent by the user application from inside the driver, machine gets into
    booting ...
    here what i did was
    in wput routine
    struct user_data *u_data;    
    u_data =(struct user_data*)mp->b_cont->b_rptr;      
    cmn_err(CE_NOTE,"minor= %d",u_data->minor);
    till here working well..
    where as..
    cmn_err(CE_NOTE,"data= %s",u_data->data);
    causing panic to the system...booting happens.
    please help me out ..
    thank u all
    ss vasu

    looks like the data pointed to by 'data' is not copied from user space to kernel space.
    u_data.data=buf, just makes pointer assignment, does not copy data pointed to by buf.
    two solutions:
    1. Declare data as a array(char data[10] or something
    2. Copy buf after the structure and point data to it. strioctl.ic_len should be set to sizeof(struct) +
    data size.
    -Vijay
    is there any equivalent to strncpy() to use inside
    the driver for copying user sent data to local buffer
    i used I_STRioctl and assigned struct to
    strioctl.ic_dp
    as shown below..
    char * buf;
    struct user-data
    int minor;
    char* data;
    struct user_data u_data;
    buf="hello world"
    u_data.minor=0;
    u_data.data=buf;
    strioctl.ic_dp=&u_data;
    strioctl.ic_len=sizeof(struct user_data);
    ioctl(fd,I_STR,&strioctl);
    when i tried to copy/access the string sent by the
    user application from inside the driver, machine gets
    into
    booting ...
    here what i did was
    in wput routine
    struct user_data *u_data;
    u_data =(struct user_data*)mp->b_cont->b_rptr;
    r;
    cmn_err(CE_NOTE,"minor= %d",u_data->minor);
    till here working well..
    where as..
    cmn_err(CE_NOTE,"data= %s",u_data->data);
    causing panic to the system...booting happens.
    please help me out ..
    thank u all
    ss vasu

  • Access Java object from Javascript

    Hi
    I'm trying to invoke a Java object from Javascript (scriptengine and all that).
    I want to add scripting features to a GeneXus Java generated app... and I have very basic skills on java too. Sorry for that ;o).
    This is the java code to pass "params" to the scriptengine:
    engine.put("remoteHandle",remoteHandle);
    engine.put("context", context); The remoteHandle (int) and context (com.genexus.ModelContext) pass trough all the gx-java generated programs.
    This javascript works fine:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle).execute( ) ;The remoteHandle conversion is ok (javascript-number to int). The context is optional.
    But if I want to pass context:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle, context).execute( ) ;Fails with this:
    "javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Java constructor for 'uftestjs' with arguments 'number,javax.script.SimpleScriptContext' not found."
    Obviously, no conversion is possible with context (javax.script.SimpleScriptContext to com.genexus.ModelContext).
    There is some way to reference de original context, by the object Id??? or something like that???
    Thanks in advance for any replies!!!
    Greetings from Chile. (I hope you can understand my english!)

    Hi
    Well, since this topic is about java programming I think the place is right here.
    (I use some tricks to embed java statements in genexus objects...)
    I will try to get some help at Artech (GX) on how to build something... to get the conversion needed.
    But they are not focussed on support this kind of questions.
    Anyway, I want to know: do I can to reference an object by the objId?
    I want to code something like this:
    com.genexus.ModelContext context =
                     (com.genexus.ModelContex)getTheObjectFromTheJVM(theObjectId);(powered by google translator, ha!)

  • Access java properties from C++/JNI program

    Hello all,
    Is it possible to access the Java properties of a JNI VM from a C++ program?
    If so, could the code or process be explained to me.
    I want to be able to identify a specific VM that is retrieved by the JNI_GetCreatedJavaVMs
    call. I set a user property when the VM was created, and would like to verify its value
    before calling AttachCurrentThread.
    Thanks in advance.
    Mark

    Are you saying that you set a system property (via System.setProperty() or -D)?
    If so, just use the JNI invocation API to call System.getProperty().
    Without error checking, that looks something like this:bool isMySystem( JNIEnv* env ) {
      const string PropertyName = "IsMySystem";
      jclass systemClass = env->FindClass( "java/lang/System" );
      jmethodID getPropertyMethod = env->GetStaticMethodID( systemClass, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;" );
      jstring propertyNameString = env->NewStringUTF( PropertyName.c_str() );
      jstring propertyString = env->CallStaticObjectMethod( systemClass, getPropertyMethod, propertyNameString );
      if ( propertyString == 0 ) {
        return false;
      const char* property = env->GetStringUTFChars( propertyString, 0 );
      boolean isMine = ! strcmp( property, "Yes" );
      env->ReleaseStringUTFChars( propertyString, property );
      return isMine;
    }Using Jace, http://jace.reyelts.com/jace (a free, open-source toolkit), this would look more like:bool isMySystem() {
      String property = System::getProperty( "IsMySystem" );
      return property.isNull() ? false : prop == "Yes";
    }In the end, Jace ends up making all of the exact same calls, but you can see how much easier it is to use.
    God bless,
    -Toby Reyelts

  • Accessing Java objects from C++ client

    I have a number of Java CORBA server objects that I have deployed to an 8.1.7 database.
    I can invoke these objects from a Java client with no problem, but I also need to access them from a C++ client.
    I have used idl2cpp from VisiBroker for C++ (version 4.5) to generate the client stubs, and I've downloaded the interop.tar file from http://technet.oracle.com/products/oracle8i/htdocs/jserver_faq/interop.tar
    The problem that I have is that I have not been able to build a client program because login.lib from interop.tar generates conflicts at link time. I've tried everything that I can think of, but I always end up with either missing references or multiply defined symbols. I've tried building using both MS Visual C++ and Borland C++Builder, but with no success.
    Has anybody succeeded in building a C++ client? Surely it shouldn't be this difficult?
    Thanks,
    Tony

    Thank u for taking care of me
    But the hint given by u is not apt to my query.
    If any new suggestion pls send again

  • Accessing java fields from c++

    I have created a JNI app that needs to access the fields of the java object but when I try to access them I get an error message saying "no such field."
    When I created my header file with javah I got (JNIEnv *, jclass and jobject) as my parameter list not JNIEnv * and jobject like all the documentation does.
    then i try to access the fields with :
    fidZone = env->GetFieldID(cls, "zone","I");
    which generates the error mentioned.
    Any suggestions will be greatly appreciated.
    Cheers.

    1. Here is the native code:
    #include <jni.h>
    #include <stdio.h>
    #include "worldfl.h"
    //header for external DLL I want to access
    #include "GDAit.h"
    JNIEXPORT jlong JNICALL
    Java_worldfl_TransProjectPt(JNIEnv *env, jclass cls, jobject obj)
    jfieldID fidx, fidy, fidStr, fidZone, fidTrDir;
    long zone, agd2gda, iResult = 0;
    double transX, transY, newX, newY, accX, accY;
    /* GET the X & Y values of the coords in the world file */
    cls = env->GetObjectClass(obj);
    printf("%ld\n", cls);
    if (cls != NULL)
    fidZone = env->GetFieldID(cls, "zone","I");
    fidTrDir = env->GetFieldID(cls, "agd2gda","I");
    fidx = env->GetFieldID(cls, "transX","D");
    fidy = env->GetFieldID(cls, "transY","D");
    /*fidStr = env->GetFieldID(cls, "filename","Ljava.lang.String");*/
    transX = env->GetDoubleField(obj, fidx);
    transY = env->GetDoubleField(obj, fidy);
    zone = env->GetDoubleField(obj, fidZone);
    agd2gda = env->GetDoubleField(obj, fidTrDir);
    iResult = 0;//TransProjPt("f:\\coordcalcs\\A66 National (13.09.01).gsb", agd2gda, transX, transY, zone, &newX, &newY, &accX, &accY);
    else
    printf("Class is NULL\n");
    //env->GetDoubleField(obj, fidx) = newX;
    //env->GetDoubleField(obj, fidy) = newY;
    return(iResult);
    2. Yes it is defined as static
    private native static long TransProjectPt(worldRead wr);

  • Accessing Java Classes from Webservice Stubs

    So far I have been able to call a web service and copy the appropriate directories and files to the designated class path.  I can also successfully access a class file like this:
    MyObject = CreateObject("java", "ca.x.y.z.TestCollection.TestItem");
    However, whenever I try to do something with that variable, I get a white screen.  Any text that should have appeared before the command, will appear, but nothing appears afterwards, not even debugging info.  Here are a couple of commands that will cause this to happen.
    <cfdump var = "#MyObject#">
    MyObject = CreateObject("java", "ca.x.y.z.TestCollection.TestItem").init();
    x = MyObject.init();
    Anybody have any ideas?

    Ah, nothing like a fresh set of eyes to remind of the fundamentals.  Thank you for that.
    I actually could create a normal error by calling a method incorrectly.  I would see the grey box and my debgging info would appear.  However, if I did something I expected to succeed, it would seem to stop.  Any text above that command would appear.  No error message, no de-bugging.
    But I didn't think to look in our error log.  I see things like:
    Could not initialize class com.microsoft.schemas._2003._10.Serialization.Arrays.ArrayOfstring
    or
    org.apache.axis.description.TypeDesc.(Ljava/lang/Class;Z)V
    At least it's not a mystery anymore.  Thanks again for suggesting the error log.

  • Accessing Java HttpServer from PHP;

    Hello all,
    I have created an httpserver using 'com.sun.net.httpserver'. Everything works fine except one thing.
    When i make this simple call from PHP (http://localhost:8081/something outputs an XML file):-
    $url = 'http://localhost:8081/something'; 
    $xml = simplexml_load_file($url); 
    print_r($xml); Nothing appears and it times out after sometime.
    However, while the browser is 'trying' to get the result (from PHP file) if i 'stop' my HttpServer (Java) the result suddenly appears. I am very sure i close all the streams i opened. Does anyone have any idea?
    Thanks
    Neville

    So on doing some debugging i realized that the http thread that started executing may have not exited correctly. That may explain the fact that when i shut the java server down explicitly while the 'php' code waits for some response, the response suddenly appears.
    While creating the server i am using:-
    server.setExecutor(Executors.newCachedThreadPool());In ThreadPoolExecutor.class
    Runnable getTask() { ....
    if (state == SHUTDOWN)  // Help drain queue
        r = workQueue.poll();
    else if (poolSize > corePoolSize || allowCoreThreadTimeOut)
        r = workQueue.poll(keepAliveTime, TimeUnit.NANOSECONDS);
    else
       r = workQueue.take();
    if (r != null)
        return r;
    if (workerCanExit()) {
    ...Using the debugger tool took me to the class ThreadPoolExecutor.class which seems to be the bottleneck; This condition is true (poolSize > corePoolSize || allowCoreThreadTimeOut(=false)) and it starts polling. I think maybe this is causing the problem and if it exited maybe the result would appear. Even if the corePoolSize is more than poolsize it seems to be getting stuck in r = workQueue.take();.
    I dont know how it works ok with a browser but hangs when PHP request comes into the picture. Strange...
    Thanks
    Neville

  • Accessing  java service from c++ client through wsdl

    Java service is deployed in SOAP. It has to be accessed by the client program written in c++ language. It should be done through WSDL.
    If anyone had previously faced or came to know abt this problem.
    Pls inform me abt the process.

    Thank u for taking care of me
    But the hint given by u is not apt to my query.
    If any new suggestion pls send again

  • How to access java arraylist from xslt v1?

    Hi everybody,
    I have a problem using xsl trasformation and an object that contains nested arraylistes.
    the object is structured in this way
    Request
    |---id
    |---event
    |---ListOfComponent
    |------*<List>component*
    |---------idComponent
    |---------description
    |---------*<List>properties*
    |-------------name
    |-------------value
    I'm able to get the values of id and event in this way: Request.id and Request.event;
    I'm not able to get the values of the idComponent and the name values of the list subobjects: Request.ListOfComponent.component[0].idComponent;
    When I execute the application that call the xsl trasformation i get an exeption not a vector or an array.
    So, I would like to know if is possible and if yes how can I do!
    thanks!
    Edited by: EttoreMI on 10-nov-2011 7.21
    Edited by: EttoreMI on 10-nov-2011 7.21

    Since I'm using an HP product right now I can only the exeption without stack
    Unexpected exception: java.lang.Exception: Cannot create a new transformer instance: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Illegal value: objInput.listOfComponent.component[0].idAppuntamento used for QNAME attribute: name
    localhost.localdomain     Nov 10, 2011 9:54:12 AM     TransformXML     Running Errorhandler ID #682. Workflow: 'inserisciAppuntamento', Step: 'TransformXML', com.hp.ov.activator.mwfm.component.WFException: Cannot create a new transformer instance: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Illegal value: objInput.listOfComponent.component[0].idAppuntamento used for QNAME attribute: name
    here the xsl trasformation that I wrote
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:param name="JOB_ID" />
    <xsl:param name="objInput"/>
    <xsl:param name="objInput.requestId"/>
    <xsl:param name="objInput.idOdl"/>
    <xsl:param name="objInput.evento"/>
    <xsl:param name="objInput.azione"/>
    <xsl:param name="objInput.listOfComponent.component[0].idAppuntamento"/>
    <xsl:template match="/">
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:px="http://px_request.hp.com/">
    <soapenv:Header>
         <JOB_ID><xsl:value-of select="$JOB_ID"/></JOB_ID>
    </soapenv:Header>
    <soapenv:Body>
    <px:Request>
    <requestId><xsl:value-of select="$objInput.requestId"/></requestId>
    <idOdl><xsl:value-of select="$objInput.idOdl"/></idOdl>
    <evento><xsl:value-of select="$objInput.evento"/></evento>
    <azione><xsl:value-of select="$objInput.azione"/></azione>
    <listOfComponent>
    <component type="Appuntamento">
    <pratica><xsl:value-of select="$objInput.listOfComponent.component[0].pratica"/></pratica>
    <idAppuntamento><xsl:value-of select="$objInput.listOfComponent.component[0].idAppuntamento"/></idAppuntamento>
              <property>
    </property>
    <component/>
    </component>
    </listOfComponent>
    </px:Request>
    </soapenv:Body>
    </soapenv:Envelope>
    </xsl:template>
    </xsl:stylesheet>
    I hope it is helpful in order to understand

Maybe you are looking for

  • About exception class CX_TPDA_SYS_SYMB_FSUNASSIGNED

    Can any tell me how to use this exception class. I try to use this exception class to catch unassign exception when using field symbol. But failed.Is there a way to catch unassign exception of field symbol? Thanks DATA: int TYPE I. FIELD-SYMBOL: <int

  • My ipad2 is stuck in negative color mode!

    I am new to the iPad world. But my ipad2 is stuck in like the negative color mode whereas everything is in off color. I forgot how to change it back, I know it is something to do with holding a button down. Please help!

  • MSI TV Tuners - Please Read This Topic First!

    Welcome to the forum! If you are looking for help with your MSI TV tuner, this is a good place to start before posting. Look through the stickies below, and make good use of the Search function to see if your question has been answered already. Can't

  • Accessing certain website error.

    Hello, I am in need of help. Currently, I am trying to access websites (such as ROBLOX,DeviantArt, etc.) and I have failed, I have a proxy error and I have tryed to fix my proxy issue, nothing worked, but I know that I messed with my Parental Control

  • JCO Webdynpro ESS Communication ERP User

    Hi all, i hope someone could help me here. i've to configure ESS/MSS in an ERP 2004 and i think in use a communication user (SAPJSF) to configure JCO connections. if I use SAPJSF roles SAP_ALL SAP_NEW, everything works fine but security is not the be