URGENT:  Catch a NoClassDefError within a method at runtime?

Hi there,
I have a Class A that creates an instance of Class B in method mA().
At compile time, Class A and B are both included in the CLASSPATH.
However, at runtime, Class B is removed from the CLASSPATH resulting in a NoClassDefError as expected.
NOTE: How do I gracefully handle a condition wherein I can dynamically catch this NoClassDefError? According to the javadoc, a NoClassDefError is thrown by the JVM or by the ClassLoader instance?
Hence, I have...
class A
void mA()
try {
B b = new B();
} catch (Throwable th)
System.out.println("Gracefully caught exception");
th.printStackTrace();
Note: Upon execution of (new A()).mA(), I get a console message...
Exception in thread "xyz" java.lang.NoClassDefFoundError: B
(This was probably displayed by the JVM)
This is NOT what I wanted.
I was hoping to have this gracefully caught in my try catch block.
I have the following restrictions...
1. The instance of B cannot be created using reflection. This is user code written within my application and I cannot tell him how to write code due to Java's limitation of not being able to catch a NoClassDefError at runtime.
2. I cannot use a custom class loader to detect a failure in loading this class because this application is expected to work in multiple environments containing variable parent class loader definitions.
How do I do this?

That exception is the result of loading a class not
calling any methods (including the constructor.)I definitely agree :-)
... and the class being loaded is class B. Now, my
point was that maybe the B class isn't loaded when
mA() is called, but rather when the first A is
created. (Which would load class A, which might
possibly trigger loading class B).I believe the spec disallows throwing an exception when the class is loaded for an instance that exists solely in a method. The reality of this is that it is much easier for VMs not to resolve classes until the method actually runs.
However, it can resolve it in the method any place it wants - like before try block starts executing. You can test this by creating a second method that actually calls B. Then wrap that method call in a try block inside of the constructor.

Similar Messages

  • URGENT:data type declaration of container within the method

    Hi
    My requirement is when the user revceives mail to approve/reject invoice ,the user attaches an attachmnet in the workitem stating the reson for approval/rejection of invoice.The attached attachement should be uploaded to invoice as an attachment.
    I have observed that the attachment attached by the user is stored in the container "office_document" and the type of the container is SOFM.
    To capture the attachment and send it to invoice i have created new task and new method in ZBUS2081.
    i created a container "office_doc_atta" in the workflow .the type of office_doc_atta is SOFM .
    in the method  as well as task i also declared parameter "office_doc_atta" of type sofm.
    to fetch the data from Task to method i have declared following table
    data:office_doc_atta type swc_object occurs 0 with header line.
    swc_get_table container 'office_doc_atta' office_doc_atta.
    I think that data type of "office_doc_atta" decalred within the method
    is wrong and i am unable to fetch data from the container.
    If anyone know what should be the data type of office_doc_atta within the method and how to fetch data from the task kindly let me know.
    Points will be rewarded.

    Try using SWOTOBJID instead of SWC_OBJECT.
    SWOTOBJID is the data type for a persistent object ID, while SWC_OBJECT is the data type for a runtime object ID (or reference or handle, if you are more familiar with any of those terms).
    Normally, an object will be passed by the persistent object ID. As the name reveals, the ID is persistent, i.e. remains the same. Therefore it can be stored in a database, and passed to the next step in a workflow - even if this step is executed by a different person another day.
    <i>Message was edited by Kjetil Kilhavn:</i>
    Please don't use the word urgent in your subject (or in the question for that matter). There are many reasons for this, some of which are:
    1) This is not a help desk or service organization, there are no response time guarantees based on how important a problem is for you.
    2) Most people visit SDN when time permits.
    3) Due to the previous 2 that particular word annoys more than it inspires.
    4) It is specifically mentioned in the guidelines that you should not use that word.
    5) It is a word with no accuracy. It would be better if you wrote (in the question, not the subject) that you need to solve this within 2 days - then we know your deadline.
    6) If I'm in the right mood I will ignore all questions marked as urgent for at least one day. Just for the heck of it.

  • How does one pass import parameters to a report within a method?

    Hello all,
    Well how does one  pass import parameters to a report which is within a method ...end method.
    for example :
    method 123
    SUBMIT reportname using selection '1000'
    endmethod .
    Here we need to pass values into the selection screen and run the report for those values.
    The values are say 'ABC'   (  tablename "DEF" and field name "HIJ" ).
    I hope the question is clear, awaiting your response 
    Thanks and Regards,
    Sandeep.

    Go to SE24
    Parameters: Give the Parameter name, Typing method is "Type" is the domain type that u are selecting, say for e.g :  Parameter is "P_CONT" , its associated type "CHAR32" etc
    For Select Options:  Parameter name say "S_CUST", Type"importing". For this you need to give an associated type which must be created as "TABLE TYPE " in SE11. That table type needs to have a "LINE TYPE" .
    LINE TYPE is a Structure created with components "SIGN, OPTION, LOW & HIGH" for select-Options.
    NOTE: for a Table type related to Customer data fields "say KUNNR", the line type created must have the Component Type and data Type corresponding to the Data Element associated with "KUNNR" ;i.e: "CHAR" etc.
    See if this is clear to you or revert back in case of any Confusion.

  • Calling non-static command from within static method

    Hello,
    I have a static method that reads bytes from serial port, and I want to set a jTextField from within this method. but I get error that says it is not possible to call non static method from a static one. How can it be solved?

    ashkan.ekhtiari wrote:
    No, MTTjTextField is the name of jTextFiled class instance.You haven't declared any such variable in the class you posted, not to mention that such a variable name violates standard code conventions.
    This is and instance of that object actually. You haven't declared any such variable in the class you posted.
    the problem is something else. No, it isn't, based on the information you have provided. If you want accurate guidance, don't post misleading information about your problem.
    It can not be set from within static method.A question commonly asked on Java forums concerns an error message similar to the following:
    non-static variable cannot be referenced from a static context
    In Java, static means "something pertaining to an object class". Often, the term class is substituted for static, as in "class method" or "class variable." Non-static, on the other hand, means "something pertaining to an actual instance of an object. Similarly, the term instance is often substituted for non-static, as in "instance method" or "instance variable."
    The error comes about because static members (methods, variables, classes, etc.) don't require an instance of the object to be accessed; they belong to the class. But a non-static member belongs to an instance -- an individual object. There's no way in a static context to know which instance's variable to use or method to call. Indeed, there may not be any instances at all! Thus, the compiler happily tells you that you can't access an instance member (non-static) from a class context (static).
    Once you understand this concept, you can fix your own problem.
    ~

  • Null Pointer Exception when using exec() method of runtime.

    Hi There,
    I am using a Random Access File to access text data. Then I am using the text data with the Runtime class to activate native programs (such as Word, Outlook, etc).
    I have designed my code so that the length of the text file is compared to the current file pointer. If the current file pointer is less than the length of the file then a string is loaded with the text (path) details relevant for the activation of a program (e.g.: Word). In the case where the end of text data in the file has been reached I load the relevant string with null. Here is a little run down of the code:
    String Path1;
    long FileLength = TxtFile.length(); //Find file length.
    long PointerPosition = TxtFile.getFilePointer(); //Find current position
      try
          if(PointerPosition < FileLength)
            Path1 = TxtFile.readLine();        //Read line into string
          else
            Path1 = null;                      //Make string null.
       }catch(IOException e){}Once the code above has been run I then use the Runtime class's exec() method along with path details held in the string to start a native program as follows:
        if(e.getActionCommand().equals("Word"))
          if(Path1.equals(null))
            EntryBox = new DataEntryBox();  //Create a dialog box for user.
          else
            try
              Runtime.getRuntime().exec(new String[]{Path1}); //Starts prog
            catch(IOException f){}
        }Whenever I press a button on my program that does not contain a path and instead contains the null value for the relevant string I get the following error message:
    C:\j2sdk1.4.0\bin\javaw -classpath "D:\Java\JavaQuickLauncher\classes;C:\j2sdk1.4.0\jre\lib\charsets.jar;C:\j2sdk1.4.0\jre\lib\jaws.jar;C:\j2sdk1.4.0\jre\lib\jce.jar;C:\j2sdk1.4.0\jre\lib\jsse.jar;C:\j2sdk1.4.0\jre\lib\rt.jar;C:\j2sdk1.4.0\jre\lib\sunrsasign.jar;C:\j2sdk1.4.0\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.0\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.0\jre\lib\ext\localedata.jar;C:\j2sdk1.4.0\jre\lib\ext\sunjce_provider.jar;C:\j2sdk1.4.0\lib\dt.jar;C:\j2sdk1.4.0\lib\htmlconverter.jar;C:\j2sdk1.4.0\lib\tools.jar;C:\j2sdk1.4.0\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.0\demo\jfc\Java2D\Java2Demo.jar" javaquicklauncher.Begin
    java.lang.NullPointerException
         at javaquicklauncher.GUI.actionPerformed(GUI.java:160)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:258)
         at java.awt.Component.processMouseEvent(Component.java:5021)
         at java.awt.Component.processEvent(Component.java:4818)
         at java.awt.Container.processEvent(Container.java:1380)
         at java.awt.Component.dispatchEventImpl(Component.java:3526)
         at java.awt.Container.dispatchEventImpl(Container.java:1437)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
         at java.awt.Container.dispatchEventImpl(Container.java:1423)
         at java.awt.Window.dispatchEventImpl(Window.java:1566)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
    It is my feeling that the exec() method of Runtime is causing this ream of errors, however I feel that my test condition -- if(Path1.equals(null)) -- should avoid trying to run the exec() method when the string is truly null. I am really stuck with this one, any help / suggestions will be greatly appreciated.
    Thanks for your time.

    Path.equals(null) ... and if the Path is null u ll get a NullPointerException.
    U r trying to do an equals on null.

  • Catching TimedOutException from within JWS

    I have a web service method within a JWS file that may take long amount of time to process. Occasionally, this method will cause a TimedOutException.
    I've tried creating methods for all of the callback events outlined in the "Context.Callback" interface, but none of them seem to get triggered when this particular exception occurs. I would like to be able to catch any TimedOutExceptions that are thrown and handle the errors gracefully. Is there a way to do this?
    Thanks,
    David

    Hi Setya,
    I am very sorry ..that i didnt look at the weblogic version which u were using. Actually The Resource Injection and EJB injection are defined by Servlet Specification 2.5 Onwards...WebLogic Server 10.0 implements the Servlet 2.5 specification. These features are available Only After "WebLogic 10.0" Onwards.
    So in WebLogic 9.x you cannot Inject resources.
    Thanks
    Jay SenSharma

  • Reflextions within static methods

    I need to know the name of the class within a
    static method.
    In an instance method I can just use
    this.getClass(), but not in a static method.
    I need it because I have a class that inherits
    from a singleton. But I can't use the inherited
    static method getInstance(), it gives me
    in instance of the superclass.

    I don't want to overwrite "instance" and "getInstance()",
    I only want to use them in the context of the Class "Something".
    Here is my next approach to the Idea:
    abstract public class Singelton {
         static Singelton instance = null;
         static Singelton getInstance(Class thisClass)     {
           if(instance == null)
              try {
                Constructor constructor = thisClass.getConstructor();
                instance = (Singelton)constructor.newInstance();
             } catch (Exception e) {
              e.printStackTrace();
           return instance;
         abstract public void doSomething();
    public class Something extends Singelton {
         public void doSomething()
              System.out.println("Hello world!");
         public static void main(String[] args)
              Singelton s = Something.getInstance(Something.class);
              s.doSomething();
    }The only little thing is, I would like to avoid
    the parameter "thisClass" in the method "getInstance()",
    because the method getInstance() in the class Singelton
    is call thru the class Something.

  • URGENT:  javax.xml.parsers.DocumentBuilder.parse() method issue

    Hi folks,
    I have an urgent parsing problem. I developed an app with JDK1.4 and now it needs to run on JDK1.3.1. The problem is this:
    If I use the DocumentBuilder.parse() method shipped with JDK1.4 it will parse a document containing namespaces WITHOUT a namespace declaration in the root element. However, since XML support doesn't ship with JDK1.3.1 I need to use JAXP. If I try this with the DocumentBuilder.parse() version shipped with JAXP (latest version) the parse method throws a NullPointerException. If I put the namespace declaration in the document it will parse fine. I tried setting the DocumentBuilderFactory.setNamespaceAware() explicitly to false (should be the default) but no luck. Any ideas other than adding the declaration (long story why I don't want it there...)
    thanks

    example, with declaration of namespace:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root xmlns:inn="http://blablabla/inn/version/1.0/">
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    example, without declaration:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root>
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    this may help...

  • Catching an exception within a JSP

    Hi all,
    I need to catch an exception in a JSP before the errorPage handles it. Have tried with try-catch but it seems like the exception is thrown to the errorPage anyway. Do you know of any technique to handle this.
    In other words: I would like to specify program logic for one exception within the JSP itself. Let us say Customer.Authenticate() throws an Exception when the given e-mail is not included in customer-DB. I would like to append logic instead of being redirected to errorPage.
    Anyone done this, can it even be done?
    ,Chr

    I would try keeping the error page as it is and still adding the logic in the catch block. If that does not help, then remove the error page and use <jsp:forward> (after your logic) in the catch block to explicitly go to the error page.
    or if you want to process that logic anyways in case of an exception, try adding your logic in the finally block.

  • Catching DML Exception in onCommit method, how to revert /rollback?

    Hi,
    JDev 10.1.2, ADF/Struts
    Flow: Registrate -> Confirm -> Message Registrated
    I need to catch Exception/Errors when the problems occur during the commit.
    I added a try catch block but the Exception isn't caught
    so I check to see if there are errors after the doIt gets called.
    Am I missing something?
    Other question, I tried to use the following code to keep the created row after rollback:
    AM.getTransaction().setClearCacheOnRollback(false); // to keep the created entities
    AM.getTransaction().rollback();
    but it seems that the created row is not maintained after a duplicate index exception is caught?
    I added a onCommit method in my ConfirmAction:
    public void onCommit(DataActionContext ctx)
    try {
    if (ctx != null)
    if (ctx.getEventActionBinding() != null)
    ctx.getEventActionBinding().doIt();
    if (this.hasErrors(ctx))
    System.out.println(getClass().getName()+".onCommit after doIt => hasErrors");
    // get application module
    // rollback
    // forward to registrate
    catch (Exception ex) {
    System.out.println(getClass().getName()+".onCommit Exception caught ex: "+ex.toString());
    ex.printStackTrace();
    // No exception caught if problem in Commit
    Thanks for your help
    Fred

    Hi,
    JDev 10.1.2, ADF/Struts
    Flow: Registrate -> Confirm -> Message Registrated
    I need to catch Exception/Errors when the problems occur during the commit.
    I added a try catch block but the Exception isn't caught
    so I check to see if there are errors after the doIt gets called.
    Am I missing something?
    Other question, I tried to use the following code to keep the created row after rollback:
    AM.getTransaction().setClearCacheOnRollback(false); // to keep the created entities
    AM.getTransaction().rollback();
    but it seems that the created row is not maintained after a duplicate index exception is caught?
    I added a onCommit method in my ConfirmAction:
    public void onCommit(DataActionContext ctx)
    try {
    if (ctx != null)
    if (ctx.getEventActionBinding() != null)
    ctx.getEventActionBinding().doIt();
    if (this.hasErrors(ctx))
    System.out.println(getClass().getName()+".onCommit after doIt => hasErrors");
    // get application module
    // rollback
    // forward to registrate
    catch (Exception ex) {
    System.out.println(getClass().getName()+".onCommit Exception caught ex: "+ex.toString());
    ex.printStackTrace();
    // No exception caught if problem in Commit
    Thanks for your help
    Fred

  • Find out who catches exception from within exception

    Hi,
    I am writing some generic Exception for our project. The aim is to simplify exception handling by making the exceptions log the necessary information with Log4J.
    It seems pretty easy to find out which class actually threw the exception (top of stack trace) but I would much rather like to log the exception in the name of the class that will catch the exception.
    The problem is that the stacktrace (it can be retrieved within an exception as of J2SE 1.4) does not contain information about which class will actually be catching the exception.
    Is there any way to accomplish that? Would be very grateful if someone could point me into the right direction if there is a possibility.
    Thank you very much in advance
    Greets Robbi

    Thanks for the quick reply.
    What I actually really wanted is to log from within the Exception. Right now I am doing this from within the Exceptions constructor.
    I see your point with the constructor being supposed to be lightweight, but in most cases the logging will be turned off and log4J does not take a lot of time to find that out.
    The logging within the catch blocks is what we wanted to circumvent as that would be the same in all catch blocks. Additionally it would be easy to simply change the topmost Exception in our hierarchy to log somewhere else instead.
    Performance is not too crucial on our application, but traceability is, as a lot of money is tied to a single transaction. That is why we decided to for Exceptions to log, as thus even when a developer would forget to log, the exception is still logged.
    Anyway, I thought that it is quite likely not possible to determine who catches an exception from within that exception. I guess the virtual machine wouldn't like to unseal that information. Maybe this is something that might work in a future Java version.
    Thanks for the input anyway.
    Regards Robbi

  • Using a variable from another method within another method

    I have a couple methods. In the beginning of the class I declared the double variables. Then I have a method1 that in that class that changes those double variables. Then the last method2 runs, and is suppose to print information to the screen with the changed variable information all being called from another class. How do I get those changed double variables to be read in method2?

    Sorry about all that, when I paste it in from the compiler it's skews it some, but hopefully this should be more readable
    * Project Filename: Lab1s2
    * Program Filename: Lab1s2.java
    * I/O Files used:
    * Fuction:          This program will use interactive input to ask cost of a
    *                   product in dollars and cents (eg. 17.50).  If the product
    *                   is not less than $100.00, an error message will be displayed
    *                   and input will be requested again.  Once a valid value is
    *                   given, the program will calculate the fewest bills and change
    *                   to be returned if the customer gives a $100.00 bill.
    * Formulas:         (100 - amount = change)
    * Algorithm:
    * Purpose:          The main method calls other methods found in the MoneyXX class
    *                   that will accomplish the function of the project.
    public class Lab2sl
         public static void main( String[] args ) // main method begins program execution
         Money2sl myMoney2sl = new Money2sl(); // create myMoney2sl object and assign it to Money2sl
            myMoney2sl.inputSL();// calls input method and pass argument
            myMoney2sl.changeSL(); // calls change method
            System.out.println(); // output a blank line
         myMoney2sl.outputSL(); //calls outputSL to show results
    * Project Filename: Money2SL.java
    import java.util.Scanner;
    import java.util.Calendar;
    public class Money2sl
         Scanner input = new Scanner( System.in ); // create Scanner to obtain input from command window
        private double change,
                       amount; // instant variable, stores amount
        private double twentyD = 20.00;
        private double tenD = 10.0;
        private double fiveD = 5.0;
         private double dollar = 1.0;
         private double quarter = 0.25;
         private double dime = 0.10;
         private double nickel = 0.05;
         private double penny = 0.01;
         private double numTwentyD;
         private double numTenD;
         private double numFiveD;
         private double numDollar;
         private double numQuarter;
         private double numDime;
         private double numNickel;
         private double numPenny;
        // inputSL() method gets amount, checks to see if it is under $100, stores amount into variable
        public void inputSL() //input method
             Calendar dateTime = Calendar.getInstance(); // get current date and time
            //print date and time
            System.out.printf( "%s\n", "nothing" );
            System.out.printf( "%1$ta, %1$tB. %1$te, %1$tY %1$tr\n\n", dateTime );
             //print output
                System.out.println( "Please enter the amount of money (less than $100) that you will spend: ");  // prompt
              amount = input.nextDouble();
              while ( amount > 100 )
                  System.out.println( "error - enter amount less than $100");
                System.out.println( "Please enter the amount of money (less than $100) that you will spend: ");  // prompt
                  amount = input.nextDouble();
             } // end inputSL method
        // changeSL() calculates change from amount entered out of $100
         public void changeSL()
              change = 100 - amount; // calculate change
              while(change > 0)
            if ( change - fiveD >= 0 )
                        numFiveD ++;
                       change -= fiveD;
              if ( change - fiveD >= 0 )
                        numFiveD ++;
                       change -= fiveD;
              if ( change - dollar >= 0 )
                        numDollar++;
                       change -= dollar;
              if ( change - quarter >= 0 )
                        numQuarter ++;
                       change -= quarter;
              if ( change - dime >= 0 )
                        numDime ++;
                       change -= dime;
              if ( change - nickel >= 0 )
                       numNickel ++;
                       change -= nickel;
              if ( change - penny >= 0 )
                        numPenny ++;
                       change -= penny;
         } // end changeSL method
        //outputSL() displays original amount, change dollar amount, and change in individual bills and coins
        public void outputSL()
             System.out.printf( "$%.2f dollars will return $%.2f, which is: ",
                                 amount, change );
            System.out.println(); // blank line
             System.out.println(); // blank line
            if ( numTwentyD > 0 )
                 if ( numTwentyD > 1)
                      System.out.println( numTwentyD + " twenty dollar bills" );
                 System.out.println( numTwentyD + " twenty dollar bill" );
            if ( numTenD > 0)
                 if ( numTenD > 1 )
                      System.out.println( numTwentyD + " ten dollar bills" );
                 System.out.println( numTwentyD + " ten dollar bill" );
            if ( numFiveD > 0)
                 if ( numFiveD > 1 )
                      System.out.println( numFiveD + " five dollar bills" );
                 System.out.println( numFiveD + " five dollar bill" );
            if ( numDollar > 0)
                 if ( numDollar > 1 )
                      System.out.println( numDollar + " one dollar bills" );
                 System.out.println( numDollar + " one dollar bill" );
              if ( numQuarter > 0)
                 if ( numQuarter > 1 )
                      System.out.println( numQuarter + " quarters" );
                 System.out.println( numDollar + " quarter" );
              if ( numDime > 0)
                 if ( numDime > 1 )
                      System.out.println( numDime + " dimes" );
                 System.out.println( numDime + " dime" );
              if ( numNickel > 0)
                 if ( numNickel > 1 )
                      System.out.println( numNickel + " nickels" );
                 System.out.println( numNickel + " nickel" );
              if (numPenny > 0)
                 if ( numPenny > 1 )
                      System.out.println( numPenny + " pennies" );
                 System.out.println( numPenny + " penny" );
    }

  • URGENT!! Default Vendor Payment Methods

    Hello SAP Folks,
    Question:
    Is there a way to default a vendor payment method when the payment method is not defined while creating the invoice?  Let's say in the vendor master there are 3 payment methods .. Wire, ACH payments and Checks ... there is a process that creates invoices automatically but does not specify the payment method so, I would like to have the method always be ACH BUT, if I need to change this later say in FB02, I can switch it to Checks?
    Your help per usual is very much appreciated!!
    Jay
    Edited by: Jay J. Esparza on Aug 3, 2008 5:13 AM

    You can rather specify only ACH in Vendor Master. This setting will default ACH always while payment. However if you like to use different one, you can change in Fb02. Payment method at document level always overrides Master record setting.
    Hope this helps

  • Why does using a static jclass variable within a method crash the JVM?

    I have some native code, that in a single thread, loops over a Java method. To improve performance, I tried this:
        static jclass clazz = env->FindClass("foo");
        /*FIXME: GetStaticMethodID crashes with "Bad global or local reference"*/
        jmethodID mid = env->GetStaticMethodID(clazz, "makeEvent", sig);But with the static declaration of clazz, the JVM crashes on the second iteration. Why? Is this really any different then using a C++ member field ?
    My loop is really a bit more complicated then this, in that it starts several calls up. I hate the idea of
    A) actually calling FindClass every iteration.
    B) passing the clazz pointer through 3 layers of calls, just to avoid calling FindClass
    Is there a better way?
    Thanks!

    Well I tried this, and it does not compile, becuase NewGlobalRef returns jobject not jclass.
    Yes "jclass" is a pointer to a c++ object jclass, and jclass extends _object. However,
    static jclass myGlobalRef dynamic_cast<jclass>( NewGlobalRef (myJClass));Does not compile either. The error is
    error C2683: 'dynamic_cast' : '_jobject' is not a polymorphic type
    static jclass myGlobalRef static_cast<jclass>( NewGlobalRef (myJClass));
    DOES compile, but it is very dangerous. And using static_cast when dynamic_cast fails is a super-bad idea.
    Just for laughs, I tried it anyway, and when I use -Xcheck:jni, the JVM dies with a fatal error.
    Edited by: charlweed on Sep 19, 2009 3:56 PM
    Typo

  • Problems with a while loop within a method... (please help so I can sleep)

    Crud, I keep getting the wrong outputs for the reverseArray. I keep getting "9 7 5 7 9" instead of "9 7 5 3 1". Can you guys figure it out? T.I.A (been trying to figure this prog out for quite some time now)
    * AWT Sample application
    * @author Weili Guan
    * @version 1999999999.2541a 04/02/26
    public class ArrayMethods{
       private static int counter, counter2, ndx, checker, sum, a, size, zero;
       private static int length;
       private static int [] output2, output3, reverse, array;
       private static double output;
       private static double dblsum, dblchecker, average;
       public static void main(String[] args) {
          //int
          //int [] reverse;
          System.out.println("Testing with array with the values [1,3,5,7,9]");
          size = 5;
          array = new int [size];
          reverse = new int [size];
          array[0] = 1;
          array[1] = 3;
          array[2] = 5;
          array[3] = 7;
          array[4] = 9;
          System.out.println("Testing with sumArray...");
          output = sumArray(array);
          System.out.println("Sum of the array: " + sum);
          System.out.println();
          System.out.println("Testing with countArray...");
          output = countArray(array);
          System.out.println("Sum of the elements : " + checker);
          System.out.println();
          System.out.println("Testing with averageArray...");
          output = averageArray(array);
          System.out.println("The average of the array : " + average);
          System.out.println();
          System.out.println("Testing with reverseArray...");
          output2 = reverseArray(array);
          output3 = reverseArray(reverse);
          //System.out.print(reverse[4]);
          System.out.print("The reverse of the array : ");
          for(ndx = 0; ndx < array.length; ndx++){
             System.out.print(reverse[ndx] + " ");
       private ArrayMethods(){
       public static int sumArray(int[] array){
          checker = 0;
          ndx = 0;
          counter = 0;
          sum = 0;
          while(counter < array.length){
             if (array[ndx] > 0){
                checker++;
             counter++;
          if(array.length > 0 && checker == array.length){
             while(ndx < array.length){
                sum += array[ndx];
                ndx++;
             return sum;
          else{
             sum = 0;
             return sum;
        /*Computes the sum of the elements of an int array. A null input, or a
        zero-length array are summed to zero.
        Parameters:
            array - an array of ints to be summed.
        Returns:
            The sum of the elements.*/
       public static int countArray(int[] array){
          checker = 0;
          ndx = 0;
          counter = 0;
          sum = 0;
          while(counter < array.length){
             if(array[ndx] > 0 && array[ndx] != 0){
                checker++;
             counter++;
          return checker;
        /*Computes the count of elements in an int array. The count of a
        null reference is taken to be zero.
        Parameters:
            array - an array of ints to be counted.
        Returns:
            The count of the elements.*/
       public static double averageArray(int[] array){
          dblchecker = 0;
          ndx = 0;
          counter = 0;
          dblsum = 0;
          while(counter < array.length){
             if(array[ndx] > 0){
                dblchecker++;
             counter++;
          if(array.length > 0 && checker == array.length){
             while(ndx < array.length){
                dblsum += array[ndx];
                ndx++;
             average = dblsum / dblchecker;
             return (int) average;
          else{
             average = 0;
             return average;
        /*Computes the average of the elements of an int array. A null input,
        or a zero-length array are averaged to zero.
        Parameters:
            array - an array of ints to be averaged.
        Returns:
            The average of the elements.*/
       public static int[] reverseArray(int[] array){
          ndx = 0;
          counter = 0;
          counter2 = 0;
          if(array.length == 0){
             array[0] = 0;
             return array;
          else{
                //reverse = array;
             while(ndx <= size - 1){
                   reverse[ndx] = array[4 - counter];
                   counter++;
                   ndx++;
                   System.out.print("H ");
          return reverse;
        /*Returns a new array with the same elements as the input array, but
        in reversed order. In the event the input is a null reference, a
        null reference is returned. In the event the input is a zero-length array,
        the same reference is returned, rather than a new one.
        Parameters:
            array - an array of ints to be reversed.
        Returns:
            A reference to the new array.*/
    }

    What was the original question? I thought it was
    getting the desired output, " 9 7 5 3 1."
    He didn't ask for improving the while loop or the
    reverseArray method, did he?
    By removing "output3 = reverseArray(reverse):," you
    get the desired output.Okay, cranky-pants. Your solution provides the OP with the desired output. However, it only addresses the symptom rather than the underlying problem. If you'd bother yourself to look at the overall design, you might see that hard-coding magic numbers and returning static arrays as the result of reversing an array passed as an argument probably isn't such a great idea. That's why I attempted to help by providing a complete, working example of a method that "reverses" an int[].
    Removing everything and providing "System.out.println("9 7 5 3 1");" gets him the desired output as well, but (like your solution) does nothing to address the logic problems inherent in the method itself and the class as a whole.

Maybe you are looking for