Method to kill a program

I want to be able to end a program when a certain function is executed.
I know break statements exit from while loops, switch structures etc, but I am just wondering is there a method in java which will end the program when it's called, no matter what the program is doing.

if it ends in an error condition, you can use System.exit(SOME_VALUE_NOT_ZERO);
this has no effect on java, but if the program is used in a script it may realize that something went wrong.

Similar Messages

  • How to call standard SAP method in the Custom Program ?

    Hi,
    i need to call sap standard method 'OpenItemRollinout' in my custom program. For the SAP Standard method 'OpenItemRollinoun' the BOR(Business Object) is 'PAYSCHEME'. So how to call the SAP standard method in the custom program ???

    Hi,
    In the method that you have provided only one function module is being used so better use the FM and copy the remaining code based on ur requirement.
    FM is ISU_S_PAYSCHEME_ROLLIN_ROLLOUT.
    Regards,
    Vijay.

  • How to return a object from a method in a java program to a C++ call (JNI )

    Sir,
    I am new to java and i have been assigned a task to be done using JNI.
    My question is,
    How can i return an object from a method in a java program to a call for the same method in a C++program using JNI.
    Any help or suggesstions in this regard would be very useful.
    Thanking you,
    Anjan Kumar

    Hello
    I would like to suggest that JNI should be your last choice and not your first choice. JNI is hard to get right. Since the JNI code is executing in the same address space as the JVM, any problems (on either side) will take down the entire process. It dilutes the Write Once Run Anywhere (WORA) value proposition because you need to provide the JNI component for all hardware/OS platforms. If you can keep your legacy code(or whatever you feel you need to do in JNI) in a separate address space and communicate via some inter-process channel, you end up with a system that is more flexible, portable, and scalable.
    Having said all that, head over to the Java Native Interface: Programmer's Guide and Specification web page:
    http://java.sun.com/docs/books/jni/
    Scroll down to the Download the example code in this book in ZIP or tar.gz formats. links and download the example source. Study and run the example sources. The jniexamples/chap5/MyNewString demo creates a java.lang.String object in native code and returns it to the Java Language program.

  • Need library that lets me kill Windows programs and then reopen them.

    I have issues with a certain program crashing in remote locations..cough* VzAcess. I want to create a program that tries to ping a website and if that fails then it will kill the program and then re open the program. Everywhere I look line these three libraries come up:
    import org.javagroup.process.ProcessManager;
    import org.javagroup.process.ProcessManagerHolder;
    import org.javagroup.process.JProcess;
    I cannot find anywhere where to get these. Maybe my google skills have diminished. I don't know. If anybody knows of any good and reliable libraries that let me do these things that would be great. Thanks!

    dothedru22 wrote:
    ... Everywhere I look line these three libraries come up:
    import org.javagroup.process.ProcessManager;
    import org.javagroup.process.ProcessManagerHolder;
    import org.javagroup.process.JProcess;
    I cannot find anywhere where to get these. Not sure they do what you expect.
    jsh seems to be an abandoned project; no activity since 2001/2002.

  • Function module or Method for changing a program with transport

    Hi,
    Can anybody please let me know if there is any Function module or Method to change a program under a Transport request
    (so it needs to go to next Version for the program).  I tried using
    INSERT REPORT .... with all options for this command. It is changing the program successfully but all are creating the program locally.
    I successfully found CIF_PROGRAM_INSERT for creating new program under a TR.
    But struggling a lot to find the same kind of FM or Method to change a program.
    Can anybody help?
    //Kothand

    Hi,
    Thanks. But i am asking for a Function module which can edit a program and keep it inside a Transport request.
    This FM is to import any change request.
    //Kothand

  • Calling OCX Methods from a Java Program

    Hi All,
    Is it possible to call OCX methods from a Java program? If yes, can you please refer me to any documents or sample code to achieve this.
    All inputs are highly appreciated.
    Thanks
    Tarek

    JNI
    http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • Method parameter & variable in program - "is not type compatible"

    Hi All,
    Sorry for my dummy question but by checking a few threads I couldn't find answer.
    I have a method with a paramter and calling it I get error message:
    "variable" is not type-compatible with formal parameter "parameter"
    'variable' --> data element: 'zchar2' (CHAR 2)
    'parameter' --> data element: 'zchar10' (CHAR 10)
    It's clear that 'zchar2' and 'zchar10' are different.
    What is not clear to me why cannot I import a 2 character string into a parameter of 10 characters.
    There's no error if I change the parameter's type from 'zchar10' to 'c' in the method. However I don't want this since the parameter must have 10 characters or less (and no more).
    How can I define the parameter in the method properly (I don't want to manipulate 'variable')? What is the solution?
    Thanks,
    Csaba
    Additionally:
    Tried char10, string10 - it didn't help...
    Edited by: Csaba Szommer on Mar 19, 2011 7:17 PM

    Naveen,
    Thanks for your answer.
    I want to import char2 from program (from where the method is called) into the method via a char10 parameter (export / import depends on from which point we see it).
    CALL METHOD dummy=>dummy
      EXPORTING parameter (remark: char10) = variable (remark: char2).
    Thanks,
    Csaba
    Edited by: Csaba Szommer on Mar 19, 2011 7:25 PM

  • Work area Inside a method in Object Oriented Programming

    Hi all,
    Can anyone look at the below code in the method meth1 and tell me is there any better method rather than declaring the workarea wa_itab  using t_mara.
    I can use field symbols but can i use access one field like if i say <fs>-matnr it doesnot let me do that
    I don't want to declare struture t_mara just to declare work area wa_itab. i know i can declare using field symbols like
    FIELD-SYMBOLS:<fs> type any. but how do i acess an individual field
    CLASS cls DEFINITION.
    PUBLIC SECTION.
    TYPES:BEGIN OF T_MARA,
         MATNR TYPE MARA-MATNR,
         meins TYPE MARA-meins,
    END OF T_MARA.
    data : WA_ITAB TYPE T_MARA.
    METHODS:meth1 importing itab type any table.
    ENDCLASS.
    CLASS cls IMPLEMENTATION.
    METHOD meth1.
    *FIELD-SYMBOLS:<fs> type itab."any.
    loop at itab into wa_itab. "assigning <fs>.
    write:/ wa_itab-matnr,wa_itab-meins.
    endloop.
    ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
    DATA:obj TYPE REF TO cls.
    CREATE OBJECT obj.
    TYPES:BEGIN OF T_MARA1,
         MATNR TYPE MARA-MATNR,
         meins TYPE MARA-meins,
    END OF T_MARA1.
    DATA:ITAB1 TYPE STANDARD TABLE OF T_MARA1,
             WA_ITAB1 TYPE T_MARA1.
    SELECT matnr meins FROM mara into TABLE itab1 up to 10 rows.
    CALL METHOD obj->meth1 exporting itab = itab1.
    Thanks

    I rewrote your code.
    Instead of declaring type again in the Program, I have created a table type and a public attribute IT_MARA which I have used to select the data and passed to my method to write the data.
    *       CLASS cls DEFINITION
    CLASS CLS DEFINITION.
      PUBLIC SECTION.
        TYPES:BEGIN OF T_MARA,
              MATNR TYPE MARA-MATNR,
              MEINS TYPE MARA-MEINS,
              END OF T_MARA.
        TYPES: TY_T_MARA TYPE STANDARD TABLE OF T_MARA.  " <<
        DATA: IT_MARA TYPE TY_T_MARA.   " <<
        METHODS:METH1
          IMPORTING
            ITAB TYPE TY_T_MARA.  "<<
    ENDCLASS.                    "cls DEFINITION
    *       CLASS cls IMPLEMENTATION
    CLASS CLS IMPLEMENTATION.
      METHOD METH1.
        DATA: LA_ITAB LIKE LINE OF ITAB.
        LOOP AT ITAB INTO LA_ITAB.
          WRITE:/ LA_ITAB-MATNR,LA_ITAB-MEINS.
        ENDLOOP.
      ENDMETHOD.                                                "meth1
    ENDCLASS.                    "cls IMPLEMENTATION
    START-OF-SELECTION.
      DATA:OBJ TYPE REF TO CLS.
      CREATE OBJECT OBJ.
      SELECT MATNR MEINS
        FROM MARA
        INTO TABLE OBJ->IT_MARA UP TO 10 ROWS.
      CALL METHOD OBJ->METH1
        EXPORTING
          ITAB = OBJ->IT_MARA.
    Regards,
    Naimesh Patel

  • HT4623 help with iOS7 how do you kill the programs that you visit on your phone to save the battery life?

    how to kill programs with IOS7 that you visit on your iphone to save the battery?

    Double tap Home button, swipe the app UP to delete from multitask-list.

  • Call transaction , and session  method in the same program

    hi experts,
                Can anybody tell me in which cases we will use both call transaction and session methods in same program
    if possible send me example code.
    Regards
    Trinadh

    Hi Dengyong Zhang,
    we can use the call transation and session method in same program.
    However for better performance it's benificial to use call trasaction method of BDC. but if u want to upload very large amount of data then Session method is more preferable to use.
    Session method is one of the method of BDC.
    U can also use BAPI to upload the data in SAP but it's a different concept than BDC. Performance wise BAPI is more advantageous than BDC.

  • How do you kill a program?

    When a user types in quit at my "Enter Command" prompt I wont the program to die or kill the process. Whats the command to do that?

    System.exit(0);

  • "writeOnject" Method is killing me!!

    Hi,
    I am working oa my project that uses a lot of socket programming to send objects as messages. I am having a problem with this code below.
    synchronized private void ProcessSendProbe(int i, int j)
    ObjectOutputStream sendProbe = null;
    Socket sendSocket = null;
    String toAddr = Global.myInfo.ipAddr[j]; // IP address to send
    int toPort = Global.myInfo.portNo[j]; // Port number to send
    try {
    sendSocket = new Socket(toAddr,toPort);
    } catch (UnknownHostException e) {
    System.err.println("Unknown Host: ");
    } catch (IOException e) {
    System.err.println("Failed!!");
    Node newProbe = new Node(Global.thisPid,i,j);
    newProbe._Message = "PROBE";
    try {
    sendProbe = new ObjectOutputStream(sendSocket.getOutputStream());
    sendProbe.writeObject(newProbe);
    sendProbe.flush();
    } catch (IOException e) {
    System.err.println("Failed to send object...");
    Here, the exception "Failed to send object" is always being raised no matter what I do. I tried to print some random statement just before it and it was printing. Somehow the writeObject method is messing with me. Another thing is I used the same type of code at other places in the same program and it was working fine. Right here, I cant figure out any reason. Please help me.
    Thanks,
    SJ.

    Hi,
    Here's the whole thing that I get when I include the printStackTrace() method.
    ================================================
    java.io.NotSerializableException: Probe
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Exception.java:42)
    at java.io.IOException.<init>(IOException.java:47)
    at java.io.ObjectStreamException.<init>(ObjectStreamException.java:29)
    at java.io.NotSerializableException.<init>(NotSerializableException.java:31)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
    at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at CMH_Thread.ProcessSendProbe(Project.java:337)
    at CMH_Thread.CheckToSendProbe(Compiled Code)
    at CMH_Thread.run(Project.java:281)
    ================================================
    Incompatible type for method. Can't convert void tochar[].
    System.out.println(e.printStackTrace());Don't write
    "System.out.println(e.printStackTrace());". Write
    "e.printStackTrace();" only.

  • How can i find (Debug - method) the flow of program in workflow at run time

    Hi All,
    I working in Workflow monitoring. When a workflow is set into error in SWPR , i need to analyse the error and report it. In many cases the error happens in the method of class / BOR. So i could not find out the what happens inside the method. I am doing this in an productive environment.i am not given to Run any METHOD or BOR or CLASS ? How can i make my workflow monitoring better to show exact error ?
    Thanks in advance !
    Richard A

    Dear Richard,
    You cannot debug a method by directly setting a break point as we do normally.....u can do this by
    just putting an infinite loop at the point where u want to set the debug point inside the method.
    Execute the workflow where this method is being used.
    Then go to SM50, here you will find your method which has gone into infinite loop.I debug mode change the value of the variable so that it can move ahead of the infinite loop.
    Now you can debug easily and find out where the problem lies.
    Do reply back in case of any query or even if yr problem is resolved.
    Regards,
    Geet

  • Question: Possible to assemble a method call within a program?

    I am writing an interpreter for a school project. I would like to read all instructions into an array in the format PC: Instruction: arg1: arg2: destination:
    My question is can I assemble from the Instruction name, for instance, "sqrt", a method call to public int[][] sqrt(int[][] varValue, int x, int d)? Is that even possible?
    The challenge for me is, after having written all opcode instructions as methods, how do I call them after I read a text string? Is this even a good approach to algorithm design?
    Thank you for your input.

    Ebodee wrote:
    My question is can I assemble from the Instruction name, for instance, "sqrt", a method call to public int[][] sqrt(int[][] varValue, int x, int d)? Is that even possible?Sure.
    The challenge for me is, after having written all opcode instructions as methods, how do I call them after I read a text string? So you have an array of instructions, and you have a bunch of methods that implement the instructions, right?
    (BTW, are the instructions really like sqrt? Because a more normal assignment would probably have you implement instructions like add, increment, store, etc.)
    You could use reflection to get the methods, but that's kind of a hack and a cheat (because it diverges even further from an emulation -- it's harder to map meaningfully to hardware. (This is just my opinion of course.))
    What I'd suggest is to create an Opcode interface, with a method like "void invoke(Object... args)". Then create an implementation of that for each opcode. Put objects of those methods into a Map<String, Opcode>. Then you can look them up by name.
    Is this even a good approach to algorithm design?You're not really designing an algorithm here. It sounds like you're building an virtual processor of some kind. Quicksort is an algorithm. A simulation of a computer is an application.
    Whether it's a good approach... it depends a lot on the assignment. At some point you're going to have to relinquish behavior from the emulation and let Java do some kind of bare computation. (You can't emulate everything; at some point lower-level software or hardware has to handle the semantics of what's going on.) The answer to your question depends on what level does the teacher want you to stay on. Can you write a sqrt function in Java and invoke it from your emulator, or do you have to write sqrt in the machine code of the emulator?

  • Methods to write JMS program other than MDB

    HI guys,
    Could you please help me out.
    I need to call a webservice using JMS.I know how to write a JMS message consumer or producer using MESSAGE DRIVEN BEAN,but i would like to know is there any other technologies to write JMS message consumer or producer.
    Thanks

    You might need to reword that!
    JMS is a specification for java messaging and doesn't directly support web services. If you mean that upon receiving a message you want to invoke a remote web service, then it's easy. Simply write a message consumer that calls the web service from the onMessage method.
    You should be able to do this using an MDB or a JMS Listener (See the MessageListener J2EE interface).
    I'd recommend using XFire for the web service invocation and you may also look at Lingo (which after 1 year is still on my TODO list of things to check out)

Maybe you are looking for