How to Invoke two java methods parallaly

Hi,
I need to invoke two Java methods parallaly ,for example if i am having two methods in a class
public class Test {
    public Test() {
    public static void main(String[] args)
    Test test = new Test();
    String returnString1 = test.test1();
    String returnString2 = test.test2();
    public String test1(){
    String newString1 = "";
    return newString1;
    public String test2(){
    String newString2 = "";
    return newString2;
}if i run the above class two methods will be invoked one by one(Sequentially).is there any possibility to invoke these two methods parallaly (ie) both methods need to be invoked at the same time.

import java.lang.reflect.Method;
class Paralell implements Runnable{
      private Object srcObject;
      private String methodName;
      private Class parameterTypes[];
      private Object parameterArgs[];
      private Object returnObject;
      public Paralell(Object srcObject, String methodName, Class parameterTypes[], Object parameterArgs[]){
          this.srcObject = srcObject;
          this.methodName = methodName;
          this.parameterTypes = parameterTypes;
          this.parameterArgs = parameterArgs;
      public Object getReturnObject(){
         return this.returnObject;
      public void run(){
           Method method = null;
            try{
                method =  srcObject.getClass().getDeclaredMethod(this.methodName,this.parameterTypes);
                this.returnObject =method.invoke(this.srcObject,this.parameterArgs);  
            }catch(Exception exp){
               exp.printStackTrace();
            }finally{
                method = null;
}

Similar Messages

  • Is there a tutorial on - how to call static java methods

    I have defined external JAVA resource using a .jar file and have successfully catalogged the same. Now I need to pass variables to a static method in a class and also get the return variable mapped into a BPM variable.
    Can someone share sample Java Invokation code, how to call methods in a class, how to instantiate a singleton or reference an existing instance of singleton class.
    Any sample code or sample projects will be useful.
    Also can I se ethe java system.out.println output in BPM Logviewer
    Arvind

    Hi Arvind,
    Sure you've done this, but the first step is to catalog the Jar file. Before an Oracle BPM project can use the Java component, the appropriate Java JAR files must be added to the project.
    Add the Jar File(s) to the External Resources:
    1. Right-click the External Resources item in the Project Navigator tab
    2. From the pop-up menu, select New External Resource.
    3. Name this new Java resource "MyNewJavaComponents" and ensure its type is Java Class Library.
    4. Add the Java jar file(s)
    Catalog and Expose the Java Components:
    5. Add a new module in the Catalog called "IntegrationComponents".
    6. Generate a Java integration component by right-clicking the IntegrationComponents module and select "Catalogue Component" -> "Java".
    7. Using the Java configuration you just created called MyNewJavaComponents, click the Next button to automatically introspect the Java libraries.
    8. Select the class where your method(s) are located and click the Next -> Finish buttons to have Oracle BPM generate the integration component for you.
    9. If you expand the newly exposed Java component, you can see a method has been created for each public method (attributes would also be automatically created if this class had any public attributes). If you've included the appropriate BeanInfo class in the JAR, you'll note that the method parameters are appropriately named.
    How to Invoke Public Java methods Exposed in the Catalog:
    10. Open the method editor for an automatic activity in the process (or any BPM Object method with its "Server Side" property set to "Yes").
    11. Drag one of the Java methods you just exposed inside your IntegrationComponents module into the automatic activity's method. Once you drag it in, here's what you might see if you're using the Java syntax in Oracle BPM's method editor:
    (PdfGenerator).generate(outputFilename : "", contents : {  }, logoImageURL : null, signatureImageURL : null);
    Assuming you have "outputFilename", "sampleContent", "logoURL" and "signatureURL" variables already created in your process, change the method you just dragged in to:
    IntegrationComponents.Pdfservice.PdfGenerator.generate(outputFilename : outputFilename, contents : sampleContent,
    logoImageURL : logoURL, signatureImageURL : signatureURL);
    Hope this helps,
    Dan

  • How to invoke another Java file in Java program?

    Hello all,
    Now I am building a commnity of agents that can talk in Java, I have another Java-Based dialogue system to handle the dialogue between the agents. But I don'y know how to invoke the Java dialogue system file in the agent class.
    Is there any methods can call another .java file in a Java program?
    Help!!!!!please

    Yep, vaguest of the vaguey vague vague.
    Anyhoo,
    I'm guessing you want to call a method from a different class?
    Assuming you have the "Runner" class and then "Agent1", "Agent2", etc.
    Agent1 whatever = new Agent1();

  • Obiee 11.1.1.6  Actions- Invoke a Java Method screen is empty

    Hi All,
    I have created and deployed an EJB for obiee11g by using the example provided in the below link
    http://www.rittmanmead.com/2010/09/oracle-bi-ee-11g-action-framework-java-ejbs-and-pdf-watermarks/
    I have mapped oracle.bi.actions also
    But I am not able to see the java method in the obiee11g Actions- Invoke a Java Method screen .The screen is empty
    I have configured the ActionFrameworkConfig.xml as follows
    <?xml version="1.0" encoding="UTF-8"?>
    <obi-action-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="afconfig.xsd">
    <aliases/>
    <registries>
    <registry>
    <id>reg05</id>
    <name>WaterMark EJBS</name>
    <content-type>java</content-type>
    <provider-class>oracle.bi.action.registry.java.EJBRegistry</provider-class>
    <description>WaterMark BIEE</description>
    <location>
    <path/>
    </location>
    <custom-config>
    <ejb-targets>
    <appserver>
    <context-factory>weblogic.jndi.WLInitialContextFactory</context-factory>
    <jndi-url>t3://localhost:9704</jndi-url>
    <server-name>localhost</server-name>
    <account>WLSJNDI</account>
    <ejb-exclude>mgmt</ejb-exclude>
    <ejb-exclude>PopulationServiceBean</ejb-exclude>
    </appserver>
    <ejb-app>
    <server>localhost</server>
    <app-context>watermark</app-context>
    </ejb-app>
    </ejb-targets>
    </custom-config>
    </registry>
    </registries>
    <content-types>
    <content-type>
    <typename>webservices</typename>
    <displayname>Web Services and BPEL Processes</displayname>
    <actionType>WebServiceActionType</actionType>
    </content-type>
    <content-type>
    <typename>misc</typename>
    <displayname>Mixed Services</displayname>
    <actionType>URLActionType</actionType>
    </content-type>
    <content-type>
    <typename>java</typename>
    <displayname>Java Services</displayname>
    <actionType>JavaActionType</actionType>
    </content-type>
    </content-types>
    <accounts>
    <account>
    <name>WLSJNDI</name>
    <description>Account used to access WLS JNDI.</description>
    <adminonly>false</adminonly>
    <credentialkey>JNDIUser</credentialkey>
    <credentialmap>oracle.bi.actions</credentialmap>
    </account>
    </accounts>
    </obi-action-config>
    Please help me to resolve this issue
    Regards
    Deepz

    1. check your t3 port no, in my case it's 7001.
    so i changed "<jndi-url>t3://localhost:9704</jndi-url>" to "<jndi-url>t3://localhost:7001</jndi-url>"
    2. if you run obiee 11.1.1.6.0 above, you don't need below.
    <credentialmap>oracle.bi.actions</credentialmap>
    so please drop this line.
    3. restart your server and check there's no error log when loading ActionFrameworkConfig.xml.
    Good Luck !!!

  • How to invoke a Java Program from Oracle 10g?(uRGENT)

    Hello.
    I've a query, that i have a program, that basically retreives the records from the
    oracle table and then parser this information and then insert the values in corresponding database base tables. I want that, whenever the new program is inserted, a Trigger should fire and pass the most recently entered record to the Parser Program, means
    1) Firing a Trigge
    2)Storing the most latest data and pass it to the Parser PROGRAM
    Can someone tell me how to do this? How to invoke a Java Program from within the database? Please if anyone has examples provide me. Its very urgent and tell me what is the basic mechanism.
    Thankyou.
    Ben

    With Java Stored Procedures Java may be caleed from a database.
    http://www.oracle.com/technology/tech/java/jsp/index.html

  • FATAL ERROR in native method: Wrong method ID used to invoke a Java method

    When calling the same method second time , I get message ::
    <FATAL ERROR in native method: Wrong method ID used to invoke a Java method>
    void myFunction(int myVal)
    JNIEnv *env = NULL;
    jclass odbcconnls;
    jint res;
    printf("\nInitilaizing class ");
    res = (jvm)->AttachCurrentThread((void **)&env,NULL);
    if (res < 0) {
    fprintf(stderr, "Can't get Env \n");
    (jvm)->DestroyJavaVM();
    return SQL_ERROR;          
    if(res == JNI_OK)
    printf("\nThe env is initialized ");
    if(*(&env) == NULL)
    printf(" the env is NULL ");
    printf("\nenv :::::: %s ", env);     
    // the jobject (dbc->actualConn) is a global reference
    odbcconnls = (env)->GetObjectClass(dbc->actualConn);
    if (odbcconnls == NULL) {
    goto destroy;
    switch(myVal){
    case 1:
    jmethodID methodId ;
    jboolean jbool;
    SQLINTEGER Val = (SQLINTEGER )Value;
    SQLINTEGER val1 = *Val;
    methodId = (env)->GetMethodID( odbcconnls,"myFun1","(Z)V");
    if(methodId == NULL){
    goto destroy;
    if(val1 == SQL_FALSE )
    jbool = 0;
    else
    jbool =1;
    env->CallVoidMethod(dbc->actualConn,methodId,jbool);
    env->DeleteLocalRef((jobject)res);
    env->DeleteLocalRef((jobject)odbcconnls);
    env->DeleteLocalRef((jobject)methodId);
    jvm->DetachCurrentThread();
    return ;
    case 2 :
    jmethodID methodId1 ;
    SQLUINTEGER* Level;
    methodId1 = (env)->GetMethodID( odbcconnls,"myFun2","(I)V");
    if(methodId1 == NULL){
    goto destroy;
    Level = (SQLUINTEGER *)Value;
    env->CallVoidMethod(dbc->actualConn,methodId1,(int)*Level);
    dbc->txn_isolation = (SQLUINTEGER)Value;
    env->DeleteLocalRef((jobject)res);
    env->DeleteLocalRef((jobject)odbcconnls);
    env->DeleteLocalRef((jobject)methodId1);
    jvm->DetachCurrentThread();
    return ;
    case 3 :
    SQLCHAR* Cate;
    jmethodID methodId2 ;
    jstring jStrCat;
    methodId2 = (env)->GetMethodID(odbcconnls,"myFun3","(Ljava/lang/String;)V");
    if(methodId2 == NULL){
    goto destroy;
    Cate = new SQLCHAR[20];
    strcpy((char *)CCatalog,(char *)Value);
    jStrCat = env->NewStringUTF((char *) Cate);
    printf("\n got jSTring ");
    env->CallVoidMethod(dbc->actualConn,methodId2,jStrCat);
    printf("\n after called method ");
    int len = strlen((char *)Cate);
    dbc->Cate = new SQLCHAR[len+1];
    strcpy((char *)dbc->Cate,(char *)Cate);
    printf("\n copied result ");
    env->DeleteLocalRef((jobject)res);
    env->DeleteLocalRef((jobject)odbcconnls);
    env->DeleteLocalRef((jobject)methodId2);
    jvm->DetachCurrentThread();
    return ;
    destroy:
    if ((env)->ExceptionOccurred()) {
    (env)->ExceptionDescribe();
    jvm->DetachCurrentThread();
    (jvm)->DestroyJavaVM();
    return SQL_ERROR;
    When case 1 is called second time this error is thrown..
    plz help me..
    Thanx
    MittalSunita.

    When calling the same method second time , I get
    message ::
    <FATAL ERROR in native method: Wrong method ID used
    d to invoke a Java method>
    void myFunction(int myVal)
    JNIEnv *env = NULL;
    jclass odbcconnls;
    jint res;
    printf("\nInitilaizing class ");
    res = (jvm)->AttachCurrentThread((void **)&env,NULL);
    if (res < 0) {
    fprintf(stderr, "Can't get Env \n");
    (jvm)->DestroyJavaVM();
    return SQL_ERROR;          
    if(res == JNI_OK)
    printf("\nThe env is initialized ");
    if(*(&env) == NULL)
    printf(" the env is NULL ");
    printf("\nenv :::::: %s ", env);     
    // the jobject (dbc->actualConn) is a global
    reference
    odbcconnls = (env)->GetObjectClass(dbc->actualConn);
    if (odbcconnls == NULL) {
    goto destroy;
    switch(myVal){
    case 1:
    jmethodID methodId ;
    jboolean jbool;
    SQLINTEGER Val = (SQLINTEGER )Value;
    SQLINTEGER val1 = *Val;
    methodId = (env)->GetMethodID(
    ( odbcconnls,"myFun1","(Z)V");
    if(methodId == NULL){
    goto destroy;
    if(val1 == SQL_FALSE )
    jbool = 0;
    else
    jbool =1;
    env->CallVoidMethod(dbc->actualConn,methodId,jbool);
    env->DeleteLocalRef((jobject)res);
    env->DeleteLocalRef((jobject)odbcconnls);
    env->DeleteLocalRef((jobject)methodId);
    jvm->DetachCurrentThread();
    return ;Why do you delete a local reference???
    Did you ever call the get local reference?
    case 2 :
    jmethodID methodId1 ;
    SQLUINTEGER* Level;
    methodId1 = (env)->GetMethodID(
    ( odbcconnls,"myFun2","(I)V");
    if(methodId1 == NULL){
    goto destroy;
    Level = (SQLUINTEGER *)Value;
    env->CallVoidMethod(dbc->actualConn,methodId1,(int)*Le
    el);
    dbc->txn_isolation = (SQLUINTEGER)Value;
    env->DeleteLocalRef((jobject)res);
    env->DeleteLocalRef((jobject)odbcconnls);
    env->DeleteLocalRef((jobject)methodId1);
    jvm->DetachCurrentThread();
    return ;
    case 3 :
    SQLCHAR* Cate;
    jmethodID methodId2 ;
    jstring jStrCat;
    methodId2 =
    (env)->GetMethodID(odbcconnls,"myFun3","(Ljava/lang/St
    ing;)V");
    if(methodId2 == NULL){
    goto destroy;
    Cate = new SQLCHAR[20];
    strcpy((char *)CCatalog,(char *)Value);
    jStrCat = env->NewStringUTF((char *) Cate);
    printf("\n got jSTring ");
    env->CallVoidMethod(dbc->actualConn,methodId2,jStrCat)
    printf("\n after called method ");
    int len = strlen((char *)Cate);
    dbc->Cate = new SQLCHAR[len+1];
    strcpy((char *)dbc->Cate,(char *)Cate);
    printf("\n copied result ");
    env->DeleteLocalRef((jobject)res);
    env->DeleteLocalRef((jobject)odbcconnls);
    env->DeleteLocalRef((jobject)methodId2);
    jvm->DetachCurrentThread();
    return ;
    destroy:
    if ((env)->ExceptionOccurred()) {
    (env)->ExceptionDescribe();
    jvm->DetachCurrentThread();
    (jvm)->DestroyJavaVM();
    return SQL_ERROR;
    When case 1 is called second time this error is
    thrown..
    plz help me..
    Thanx
    MittalSunita.

  • Oracle BI EE 11g – Action Framework - Invoke a Java Method from Action links

    Hello All,
       I have a requirement to save OBIEE 11g report into shared drive. I have created a EJB by using the below link and successfully deployed the application in server(bi_server1) .
    http://www.rittmanmead.com/2010/09/oracle-bi-ee-11g-action-framework-java-ejbs-and-pdf-watermarks/
    When Im trying to call Invoke a Java method, it is showing "No Content" . Can anybody please share with me the sample "ActionFrameworkConfig.xml" file used for Invoke a Java method.
    My OBIEE version is : 11.1.1.7.131017
    Thanks.

    1. check your t3 port no, in my case it's 7001.
    so i changed "<jndi-url>t3://localhost:9704</jndi-url>" to "<jndi-url>t3://localhost:7001</jndi-url>"
    2. if you run obiee 11.1.1.6.0 above, you don't need below.
    <credentialmap>oracle.bi.actions</credentialmap>
    so please drop this line.
    3. restart your server and check there's no error log when loading ActionFrameworkConfig.xml.
    Good Luck !!!

  • How to invoke a java class dynamically?

    Hi all,
    In my usecase I need to invoke a java class dynamically using any of the components like Button or link in jdeveloper.
    How could we invoke a java class which has a main method in it dynamically.
    Kindly come up with your help.
    Thanks,
    Phani.

    public class BackingBean {
    public BackingBean() {
    super();
    public void cb3_action() {
    File fileObj = new File("C:\\Jdeveloper software\\new.doc");
    IDocument myDoc = new Document2004();
    myDoc.addEle(Heading2.with("===== Headings ======").create());
    myDoc.addEle(Paragraph.with("This doc has been generated by the unit test testJava2wordAllInOne() in the class DocumentTest2004Test.java.").create());
    Table tbl = new Table();
    tbl.addTableEle(TableEle.TH, "Name", "Number of gols", "Country");
    tbl.setRepeatTableHeaderOnEveryPage();
    tbl.addTableEle(TableEle.TD, "Arthur Friedenreich", "1329", "Brazil");
    tbl.addTableEle(TableEle.TD, "Pele", "1281", "Brazil");
    myDoc.addEle(tbl);
    PrintWriter writer = null;
    try {
    writer = new PrintWriter(fileObj);
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    String myWord = myDoc.getContent();
    writer.println(myWord);
    writer.close();
    Hi john,
    these are my Backing bean and action now at the run time when I am pressing a button which has to invoke cb3_action() method.
    When I am clicking the button at the runtime I am getting the below error
    Error 500--Internal Server Error
    javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: word/w2004/Document2004
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
    In the above code if you observe I have used "IDocument myDoc = new Document2004();" line. Here this Document2004 is a class which is in one of the external
    jar files. xstream-1.3.1.jar , java2word-3.0_2011Aug02.jar , log4j-1.2.15.jar .
    these are the jar files I found in net using which I can create a word file and add all the components like table and format the txt etc..
    These jar files works in Tomcat, Jboss ,Struts
    I can even run this class and got the file created.
    But when I try to bind the method in ADF i am getting the error mentioned above.
    Kindly help me on this. Sorry for posting similar question two times on the blog.
    Sorry again if this question is wierd.
    Thanks,
    Phani.

  • How to call a java method so I can pass a file into the method

    I want to pass a file into a java method method from the main method. Can anyone give me some help as to how I pass the file into the method - do I pass the file name ? are there any special points I need to put in the methods signature etc ?
    FileReader file = new FileReader("Scores");
    BufferedReader infile = new BufferedReader(file);
    Where am I supposed to put the above text - in the main method or the one I want to pass the file into to?
    Thanks

    It's a matter of personal preference really. I would encapsulate all of the file-parsing logic in a separate class that implements an interface so that if in the future you want to start taking the integers from another source, e.g. a db, you wouldn't need to drastically alter your main application code. Probably something like this, (with an assumption that the numbers are delimited by a comma and a realisation that my file-handling routine sucks):
    public class MyApp{
    public static void main(String[] args){
    IntegerGather g = new FileIntegerGatherer();
    Integer[] result = g.getIntegers(args[0]);
    public interface IntegerGatherer{
    public Integer[] getIntegers(String location);
    import java.io.*;
    public class FileIntegerGatherer implements IntegerGatherer{
    public Integer[] getIntegers(String location){
    FileInputStream fs=null;
    try{
    File f = new File(location);
    fs = new FileInputStream(f);
    byte[] in = new byte[1024];
    StringBuffer sb = new StringBuffer();
    while((fs.read(in))!=-1){
    sb.append(new String(in));
    StringTokenizer st = new StringTokenizer(sb.toString(),",");
    Integer[] result = new Integer[st.countTokens()];
    int count = 0;
    while(st.hasMoreTokens()){
    result[count]=Integer.valueOf(st.nextToken());
    count++;
    catch(IOException e){
    //something sensible here
    finally{
    if(fs!=null){
    try{
    fs.close();
    catch(IOException f){
    return result;
    Once compiled you could invoke it as java MyApp c:\myInts.txt
    Sorry if there are typos in there, I don't have an ide open ;->

  • 10.1.3.4 - How to access custom java methods in worklist ?

    We want to invoke a custom java method inside of worklist, when the file attachments are added to the worklist. We are planning to modify the auto-generated jsp page to do the same. We have created the custom jar files, but am not sure where to deploy this jar file ? We are not able to compile the jsp /jar. Does anybody have any idea where the custom jar file goes ?

    The bpel\samples\hw\worklistapp\readme will explain you about how to do this.

  • How to link two .java files together?

    hello everybody,
    is it possible to link two or more .java files together? I mean is if I have 3 .java files. (a.java, b.java, c.java) then I have 3 .class files too. How do I use the method in other .java files. For example :
    public a extends Applet {
    // call b.class
    b();
    public b extends Applet implements ActionListener {
    void title1() {
    How to call the b.class? How to call the title1() method?
    Is it related to JAR or package??
    Thanks for helping me. v(^_^)v

    O.K, you do not link ".java" files together.
    You compile them into class files and they can create new instances of each other and and access their variables and work together.
    I recommend "Sam's Teach Yourself Java in 21 Days".
    It will start you out with the basics.
    --Ian                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

  • How to invoke a java webservices in flex

    hi people.I am new to ths flex.How to invoke java web service in flex .please reply .Thanks in advance.

    A good hands-on example to begin with web service calls..
    http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/srcview /source/main.mxml.html
    Good Luck!
    Nith
    DISCLAIMER:
    ========================================================================
    "This communication is intended only for the named recipient and others authorized to receive it.
    It contains confidential or legally privileged information. If you are not the intended recipient, please notify us immediately, and note that any disclosure, copying, distribution or action you may take in reliance on this communication is strictly prohibited and may be unlawful. Unless indicated otherwise, this communication is not intended, nor should it be taken to create any legal and/or contractual relation or otherwise. Ministry of Finance (MOF) is neither liable for the proper and complete transmission of the communication, nor for any delay in its receipt.
    Whilst MOF undertakes all reasonable efforts to screen outgoing e-mails for viruses, it cannot be held liable for any viruses transmitted by this e-mail."

  • How to modify a java method in Folder component

    Hi,
    I need to add some custom java code after a java method in Folder component (I am using UCM 10g, the java method is "buildResultSet" in service "COLLECTION_COPY_LOT").
    I defined service handler as described in Bex's book. My static table is:
    <@table custom_ServiceHandler@>
    <tr>
    <td>serviceName</td><td>handler</td><td>searchOrder</td>
    </tr>
    <tr>
    <td>Service</td><td>myPackage.MyClass</td><td>1</td>
    </tr>
    </table>
    Java code is :
    package myPackage
    public class MyClass extends ServiceHandler {
    public void buildResultSet() trows DataException,ServiceException
    ............. mu custom code
    m_service.doCodeEx("",this);
    If a change java method to addFiles and in static table Service to DocService, when i execute Checkin_new service it executes my custom code. I tried to change to loadorder, but have no success.
    Pls someone to tell me how can i modify this method or any other java method in "COLLECTION_COPY_LOT" service. Do i have to make some additional settings ? What other ways to modify java methods i should try ?
    I hope someone who has done someything like this to help me out.
    Thanks in advance

    A service handler might be the right way to run some code at the end of a service call (another way would be to make use of filters).
    First, make sure your static table is merged with ServiceHandlers.
    Secondary, change your custom method name into one that is not already in the service definition of COLLECTION_COPY_LOT (preferably a unique method name like collectionCopyLotLastAction that describes its purpose) and remove the following line from your code:
    m_service.doCodeEx("",this);Now create a service definition for COLLECTION_COPY_LOT in your custom component based on the original COLLECTION_COPY_LOT (copy paste from the original service definition) and add you own method collectionCopyLotLastAction as the last step in the service. Play with the load order to make sure CS is using your service definition of COLLECTION_COPY_LOT instead of the original.
    regards,
    Fabian

  • How to call a Java method in a C consoleapplication?

    I have to call a void method of a javaclass using a c consoleapplication. No argument are passed to it.
    I can't make an object of that class..
    This is my implementation in c (using JNI):
    void update(void)
         classn = "<name>";
         cls = (*env) ->FindClass(env, classn );
         if (cls == 0)
    printf(" Can't find class %s\n", classn );
         mid =
    (*env)->GetMethodID(env, cls, "<methodname>", "()V");
         (*env)->CallVoidMethod(obj, env ,m id);
    This goes wrong...
    The problem is that I have no jobject (obj) of the class, because I don't want one...I don't need one. How can I call that void method without an object and only using the classname..??

    You have to make the java method a static method, and use CallStaticVoidMethod.
    "static" means that the method belongs to the class, and not an object of that class.

  • How to merge two java files with InputDialog to select?Please help me!?

    //Addition Java application
    import javax.swing.JOptionPane; // import the class
    public class Addition {
    // main method
    public static void main(String[] args)
    String firstNumber, secondNumber;
    int number1, number2, sum;
    // read the first number
    firstNumber = JOptionPane.showInputDialog("Please enter a integer: ");
    // read the second number
    secondNumber = JOptionPane.showInputDialog("Please enter another integer: ");
    // data type conversion
    number1 = Integer.parseInt(firstNumber);
    number2 = Integer.parseInt(secondNumber);
    sum = number1 + number2;
    // display the result
    JOptionPane.showMessageDialog(null, "The sum is " + sum + ".", "Results", JOptionPane.PLAIN_MESSAGE);
    System.exit(0);
    //Multiplication Java Application
    import javax.swing.JOptionPane;
    public class Multiplication5
    public static void main(String args[])
    int number1, number2, number3, number4, number5, product;
    String firstNumber, secondNumber, thirdNumber, forthNumber, fifthNumber ;
    firstNumber =
    JOptionPane.showInputDialog("Please input an integer");
    secondNumber =
    JOptionPane.showInputDialog("Please input another integer");
    thirdNumber =
    JOptionPane.showInputDialog("Please input the third integer");
    forthNumber =
    JOptionPane.showInputDialog("Please input the forth integer");
    fifthNumber =
    JOptionPane.showInputDialog("Please input the fifth integer");
    number1 = Integer.parseInt(firstNumber);
    number2 = Integer.parseInt(secondNumber);
    number3 = Integer.parseInt(thirdNumber);
    number4 = Integer.parseInt(forthNumber);
    number5 = Integer.parseInt(fifthNumber);
    product = number1 * number2 * number3 * number4 * number5;
    JOptionPane.showMessageDialog(null, "The product is " + product, "Results", JOptionPane.PLAIN_MESSAGE);
    System.exit(0);
    I seek for help to merge above two java application files.
    I need to call JoptionPane.showInputDialog to prompt the user to input the operation, 1 for addition, 2 for multiplication. In this dialog, the user is expected to enter the integer of 1 or 2 for the calculation.
    Please help me ! Thank you!

    Hi CRay,
    You just need to call the main methods of the 2 classes according to "1" or "2" entered.
    It is better if the "multiplication" and "addition" are declared as methods rather than in main methods.
    Example:-
    public static void Addition()
    Then call
    Addition.addition();
    than
    Addition.main(new String[]{});
    as shown below.
    import javax.swing.JOptionPane; // import the class
    public class Test{
        public static void main(String[] args){
            // read which  operation to perform
            String operation = JOptionPane.showInputDialog("Please enter which operation : ");
            if(operation.equals("1")){
                Addition.main(new String[]{});
            else{
                Multiplication5.main(new String[]{});
    }Rose

Maybe you are looking for

  • Object generation error while saving

    Dear all, We use BI7.00. For one of our report, the structure /BIC/0CZEX_ZBSP_PP_5 is used. This is available only in our quality client under the package $TMP. When trying to do modification to one of the fields of this structure, i am not able to c

  • No Apple internet service of any kind?

    Hello all, Here is the deal: iTMS, www.mac.com, iDisk, and Software Update are all not working on both my computers. So, I did a hard reset of my AirPort Express to no avail. I removed the prefs from all apps, no dice. I can get online just fine (Im

  • How can i get my delete conversation back

    how can i get my deleted conversation back. its very important i really need those messages back . PLEASE SOMEONE HELP ME GET IT BACK WHAT DO I DO !!!!

  • History of first page in new tab is not recorded

    1) I open a new tab and a page displays (homepage, whatever), 2) I go to a new page under the same tab, 3) I go to another new page under the same tab. The Problem Is: The page in step 1) never gets recorded in the page history. I can never use the "

  • Set up network for gaming

    My friend and I have MBPs and want to set up a network so we can play against each other in XP. Can anyone tell me how we do this?