I can't call more than 1 Java method from C

Hi friends,
I my program written in C i call two Java methods, but the first method execute correct but the second display a error message:
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6d475879
Function name=JVM_FindSignal
Library=d:\jdk1.3.1\jre\bin\hotspot\jvm.dll
I inverted the functions, but ever the second function makes a error.
This is my C program:
#include "jni.h"
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
char *getclasspath()
char ambiente[100000];
static char result[200000];
strcpy(ambiente,"-Djava.class.path=");
strcat(ambiente,getenv("CLASSPATH"));
int tam=strlen(ambiente),i,tamresult=0;
for(i=0;i<tam;i++)
if(ambiente!='\\')
result[tamresult++]=ambiente[i];
else
result[tamresult++]='\\';
result[tamresult++]='\\';
result[tamresult]=0;
return result;
char **__stdcall getServerList(int sessionId)
     JavaVM *vm;
     JNIEnv *env;
     JavaVMInitArgs vm_args;
     JavaVMOption options[1];
     options[0].optionString = getclasspath();
     vm_args.version = JNI_VERSION_1_2;
     vm_args.options = options;
     vm_args.nOptions = 1;
     vm_args.ignoreUnrecognized = 1;
     jclass cls;
     jmethodID mid;
     char *retorno;
     int i=0;
     int k=0;
     int j=0;
     char aux[100][100];
     char *lista_server[20];
     char **lista_server_ret;
     /* Invoca a m�quina virtual Java */
     jint res = JNI_CreateJavaVM(&vm, (void **)&env, &vm_args);
     if (res < 0)
          printf("Can't create Java VM\n");
          exit(1);
     /* Procura pela classe */
     cls = (jclass) env->NewGlobalRef(env->FindClass("br.com.cpqd.sagre.security.argus.SagreWebWrapper"));
     if (cls == 0)
          printf("Can't found br.com.cpqd.sagre.security.argus.SagreWebWrapper class\n");
          exit(1);
     /* Procurando o metodo Java getListServerStr */
     if ((mid = env->GetStaticMethodID (cls,"getServerListStr","(I)Ljava/lang/String;")) == 0)
          fprintf (stderr,"Metodo nao encontrado Str\n");
          exit(1);
     jint param = (jint) sessionId;
     /* Executa o m�todo */
     jstring str_java = (jstring) env->CallStaticObjectMethod(cls,mid,param);
     retorno = (char *) env->GetStringUTFChars(str_java,0);
     vm->DestroyJavaVM ();
     int len = strlen(retorno);
     for(i=0;i<len;i++)
     if(retorno[i]!=' ')
          aux[k][j]= retorno[i];
          j++;
     else
          aux[k][j]='\0';
          k++;
          j=0;
     for(i=0;i<k;i++)
          lista_server[i] = aux[i];
     lista_server_ret=(char**)lista_server;
     return lista_server_ret;
char __stdcall encrypt(char clearText)
static JavaVM *vm;
static JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString = getclasspath();
/*     "-Djava.class.path=.;.\\SagreUtil.jar";*/
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = 1;
jclass cls;
jobject obj;
jmethodID mid;
char *retorno;
/* Invoca a m�quina virtual Java */
jint res = JNI_CreateJavaVM(&vm, (void **)&env, &vm_args);
if (res < 0)
printf("Can't create Java VM\n");
/* Procura pela classe */
cls = env->FindClass("br.com.cpqd.sagre.security.argus.SagreWebWrapper");
if (cls == 0)
printf("Can't find br.com.cpqd.sagre.security.argus.SagreWebWrapper class\n");
/* Procurando o metodo Java encrypt */
if ((mid = env->GetMethodID (cls,"encrypt","(Ljava/lang/String;)Ljava/lang/String;")) == 0)
fprintf (stderr,"Can't find the encrypt method\n");
exit(1);
jstring param = (jstring) env->NewStringUTF (clearText);
/* Instancia o metodo */
obj = env->NewObject(cls,mid,param);
/* Executa o m�todo encrypt */
jstring str_java = (jstring) env->CallObjectMethod(obj,mid,param);
if(str_java!=0)
retorno = (char *) env->GetStringUTFChars(str_java, 0);
else
     vm->DestroyJavaVM ();
     return NULL;
/* Destroi JVM */
vm->DestroyJavaVM ();
return retorno;
int main()
     char **teste;
     char *wilson;
     teste = getServerList(-1);
     printf("Fine %s",teste[1]);
     wilson = encrypt("blablabla");
     printf("%s",wilson);
I appreciate for any reply.
[ ]'s
Bruno

vikram ..
if u r using ms vc++ then there is an option in the directories tab to specify various include files.
if this doesn't work then u can use the command line compiler for vc++ , cl.exe. using cl u can give the -I option and specify the path of whatever file u want to add.
as for the specific file <jni.h> u can find it at :
driveletter:\jdk1.x\include
though i have never used this file as an include statement in .c files that i use for jni.
Dum Spiro Spero

Similar Messages

  • Can I manage more than one iTouch from one PC?

    A family member has an iTouch managed with iTunes on PC. Another family member would like an iTouch but does not have a computer.
    Can one manage more than one iTouch from one PC? How? Does one install separate instances of iTunes somehow on the PC for each device?
    There is also the desire to have separate Apple Store accounts for each device. We don't what synced devices.

    *How to use multiple iPods with one computer*
    The Apple support document How to use multiple iPods with one computer suggests a number of ways. I use method two (Sync with selected playlists) with a slight twist. Rather than regular playlists I set the grouping field to indicate which users should receive which tracks and create smart playlists based on the content of this field.
    e.g.
    "Alice's Tracks" is "Grouping contains Alice" + "Kind contains audio"
    "Bob's Videos" is "Grouping contains Bob" + "Kind does not contain audio"
    Tracks that both Alice & Bob want on their iPods have the grouping set to "Alice/Bob"
    etc.
    I currently manage our family's five iPods using this system, each getting a different selection to suit their tastes and the capacity of their iPod. An advantage of using the grouping field is that it is stored in file tags (for non-wav audio files anyway) so that it is relatively easy to recreate the playlists should the iTunes library get trashed. Also useful if you move files about manually as playlist membership is preserved when you delete & re-import the tracks.
    tt2

  • How can I select more than one song from the search results?

    I want to create playlists based on certain words in the song title. For example, I may want to create a playlist of all my songs with LOVE in the title.
    Doing the search is easy, but I can't select more than one song at a time. Is there any way in iTunes 12 for Windows to do this? I found an answer in iTunes for Mac, and it basically says to "un-check "Search Entire Library." " but I don't see that option in iTunes for Windows.
    Here is the link to that question: how can i select more than one song from drop down search bar
    I hope some Windows user can help me out.

    Found the "Search Entire Library" option - click on the small (VERY small for my eyesight) down arrow next to the magnifying glass. Also need to select "Filter by: Songs", and then the songs in the main window show the results.
    I'm going to leave this up on the board because 1) in case someone else has this question, and 2) I don't know how to delete it anyway.

  • Can I change more than one photo from color to black and white at one time?

    can I change more than one photo from color to black and white at one time?

    Check out iPhoto Batch Enhancer
    http://www.feroxsoft.com/ibe/index.php.en
    Regards
    TD

  • Can we call simple a java application from any one of this AS adapters

    Can we call a simple java application from any one of this AS adapters?
    Prakash
    Message was edited by:
    user629857

    You can achieve this using LiveCycle PDF Generator JAVA API. You can find required code here:
    Adobe LiveCycle * Quick Start (SOAP mode): Converting a Microsoft Word document to a PDF document using the Java API
    In parameters:
    //Set createPDF2 parameter values
    String adobePDFSettings = "Standard";
    String securitySettings = "No Security";
    String fileTypeSettings = "Standard OCR";
    "Standard OCR" file type setting will run OCR on input pdf. In the code, instead of doc file provide a pdf file. Resultant pdf will be searchable PDF i.e OCRed PDF.
    Feel feel to ask any further questions.

  • How can i transfer more than one file from server to client

    Hi,
    our requirement is transfer more than one files from server to client using the
    webutil_file_transfer.as_to_client_with_progress.One file transfer is already working in our system.If anybody know the solution please inform
    regards
    mat

    just an idea ...
    for this purpose let us put aside security concerns and other potential problems....
    -- Get the content of a server directory with Filter and create zip file
    1) create a class that implements java.io.FilenameFilter ...
    2) define accept() method ...
    3) call File.list() with the filter as a parameter. The returned array of strings will have all the names that passed through the accept() filter
    4) use java.util.Zip to create ZIP file on the server side
    -- I think it is better to create this functionality as a separate Java class, put it in required folder and after it
    -- use Forms->Program->"Import Java class" to create pl/sql wrappers, than to create wrappers for all classes and code in pl/sql
    5) use webutil to transfer file on the client
    6) use Java on client side to unzip transferred file
    if you think this is not too complicated, you should try ...
    Regards,
    Vladimir

  • How can i sync more than one folder from My Pictures to my iphone 4?, how can i sync more than one folder from My Pictures to my iphone 4?

    Hi,
    how can I sync more than one folder of pics from My Pictures on my computer to my iphone?

    http://support.apple.com/kb/HT4236

  • Can you print more than one copy from eprint.

    Does anyone know how to print more than one copy from eprint?

    Hi JJSS,
    Currently, the solution only offers one copy. If you need to print multiple copies, the workaround is to send the email multiple times.
    I work for HP.

  • Can you call more than one person on skype?

    When you are on Skype can you video chat with more than one person / conference call?

    Yes. Microsoft owns Skype. So signing in with a Microsoft Account will log you into skype on that account.
    You can initiate a multi part conference call from a computer opt an iPad that is looged on using a Microsoft Account.
    Buit you can also start a peer to peer call from your iPad.

  • Calling a external Java method from JSP - using Tomcat server

    Hi all,
    I am trying to call a method in an external Java file from my JSP. I am using Tomcat server.
    I have my class within the package package "mypackage" and it is called myclass.class. It has only one static method mymethod() which reads from a file and writes to a file.
    I compiled the java class and I put the class file under webapps/ROOT/web-inf/classes/mypackage/myclass.class
    I am trying to say something like this from my JSP file(which is under webapps/ROOT) :
    <%@ page import = "mypackage.myclass"%>
    <% myclass.mymethod(); %>
    I am not instatiating the class as its a static method.
    This is what I get while accessing my jsp file :
    javax.servlet.ServletException: try to access class mypackage.myclass from class org.apache.jsp.index_005ftest_jsp
    To put my problem in a nutshell, Can someone guide me how to access a method of an external class from a JSP page? I have a bunch of pages doing the same operation so I thought I would have it in a method and call it from every page. Even though I tried to put the file under web-inf/classes, The JSP is not able to see the class.
    Please help.
    Thanks
    -Uday

    I have a situation that is a bit similar. I have successfully used beans for storing methods used in JSPs and used by other methods in the same class as was suggested above. Now I would like to break some methods into another (utility) class since they are lower level and can be used by lots of things. They are for database operations (given a String query and String dbname, it queries and returns ResultSet for example). I want to have them in a separate class for reusability and OOP.
    I am having problems calling those public static methods in the public class from my bean that communicates with the JSP. I can't compile the class that calls the method in the database ops class. I get an error like :
    loginHelper.java:45: cannot find symbol
    symbol : variable sqlHelper
    location: class dbHelperBean.loginHelper
    and when I include the package name in the call I get
    loginHelper.java:45: cannot find symbol
    symbol : class sqlHelper
    location: package dbHelperBean
    That's strange since the package of both classes is dbHelperBean and the class is indeed called sqlHelper. I tried to compile it in the same directory as sqlHelper as well. What am I doing wrong?
    Thanks for any help.

  • How can i select more than one song from drop down search bar

    sometimes to make a playlist i will search my music library for a word & then add all the songs with that word in the title
    the drop down search bar will not allow me to select more than one song
    or
    will it?  & i just can't suss out how... maybe you know?
    if so, please tell me~!!!
    thank you

    hey i tried that before i posted this question... i tried all of the normal ways one would use to select more than one item...
    any click of any kind at all takes you out of the search drop down & into the main itunes window... where you are deposited back into the songs alphabetically... no longer are you seeing the results of the search...
    sigh
    at the risk of sounding like one of those people, the "old" itunes did not have this problem...
    grrrr... it seems to be that pesky drop down menu~ if only you could see the search results in the main list as opposed to only in the drop down thing

  • How can we select more than one item from LOV in Query_Find form?

    Hi,
    I have a requirement i.e i want to select more than one customer number seperated by comma from the customer number lov field in the query_find form.How can we write the code for this requirement?
    and after clicking find it has to display notification form which contains the details of customer which you selected from Custome query_find form.
    Could you please help me out.
    Thanks in Advance,
    Dhana

    Found the "Search Entire Library" option - click on the small (VERY small for my eyesight) down arrow next to the magnifying glass. Also need to select "Filter by: Songs", and then the songs in the main window show the results.
    I'm going to leave this up on the board because 1) in case someone else has this question, and 2) I don't know how to delete it anyway.

  • How can I remove more than 100 emails from an SMPT account on  iOS 7 iPad?

    Is it possible to move or remove  a large number of emails from my inbox without having to check each message individually? If you delete the message from a web email account (SMTP) will that in turn remove those emails  from my iPad Mail inbox. I have an iPad 4th  Generation with iOS 7.0.3. Any suggestions would be appreciated.
    Thanks

    Although you can use more than one Apple ID on the device at a time, only one at a time can be used for EACH FEATURE like iTunes, Facetime and iMessages,

  • Can we call a simple java application from ESB

    Please let me know how this can be done by using a ESB. The application jar exists on the host server. How we can pass parameters etc and receive results from this application.
    Any help will be greatly appreciated.
    Prakash

    Not sure if I completely understand your question, but you can certainly try following ways:
    - call your java application via WSIF. ESB with JAVA wsif is available in 10.1.3.3.1 only (it is not supported in 10.1.3.3 very well).
    - you will have to include this jar file in server.xml or bpel/system/classes so that it is available to the SOA jvm.
    - You mentioned it is simple java application, but if your java API has complex (object) input and output, you will need some work
    HTH,
    Chintan

  • Can you display more than one library from the same account?

    If I open iTunes on two computers in my house, I can only show one library on my apple tv. When I turn on the second computer, the first library goes away.
    Can you show one at the same time?
    Thanks

    Welcome to the Apple Community.
    Yes you can share more than one library at a time, just make sure that the homesharing ID and password you use for each one is the same on all of the libraries.

Maybe you are looking for

  • Box in JApplet?!

    Just a quick question.. I have no problems with using Box Layout in a Java application, but the minute I try to use Box in an applet nothing appears! Can I use Box in JApplets?! Thanks :-)

  • Satellite P750 - touch pad and internet connection not working

    Touch pad stopped working a few months ago and now can only get internet via the modem. Apparently need a new driver. Where do I access this and how do I get the touch pad working again.

  • PO repeat output

    Hi guru's the PO Automatic output determination-Print immediately is set with Z form attached in NACE the Output is printed. the Changed PO is printed. I can also have repeat output (N numebr of times) of the original PO (message line item without ch

  • Sub: Screen doesnt fit

    Sub: Screen doesnt fit Hi friends, I cant able to get full screen when I run applications in my laptop having 10 inches screen those developed in desktop having 15 inches screen, is there any forms property we can set so that every where it should fi

  • IOS 8 Hidden Photo Data

    Okay, I'm running iOS 8.1.3 on my iPhone 6 and trying to clean off space. I have cleared off ALL of the pictures in the photo app, even in the deleted pictures folder. However, for some reason iTunes and the Settings app say I have 1.1GB of space tak