About Java method

I need to design a Java method. The signature is like:
void methodAbc( in String abc, out String def )
After passing 'abc' to this method and finishing manipulation, how can I get the return value from 'def'?
thank you.

The only way I can think of is to wrap your the value into another class.
This results in the TERRIBLE code that follows (please don't shoot me !):
public class StringThing{
    public StringThing(){
        String thing=new String("");
        System.out.println("Before : "+thing.getString());
        methodAbc("Aaargh !",thing);
        System.out.println("After : "+thing.getString());
    public void methodAbc(java.lang.String abc,String def){
        def.setString(abc);
    public static void main(java.lang.String[] args){
        new StringThing();
    // This is horrible...
    public class String{
        private java.lang.String wrapped;
        public String(java.lang.String wrapped){
            this.wrapped=wrapped;
        public java.lang.String getString(){
            return wrapped;
        public void setString(java.lang.String value){
            wrapped=value;
}Hope you hate it as much as I do.
If you execute this, you will see that - in apparance the string called "thing" has changed. But it hasn't - its content has changed but not the String itself - that's the trick. This is the only way to simulate passing parameters by address in Java.
Please DON'T use this solution - no one will be able to read crappy code like that. Let alone maintain it.
It's just an example to show simulating passing params. by address.
BadLands

Similar Messages

  • I need an example about loading java method to Oracle

    Hi,
    Could anyone give me an simple example of a Java method which will be loaded into Oracle.
    Let say, the method will read the email address based on employee_ID from a table called Employee. Thank you very much for all your help.
    Hellenie
    PS: I would like to see java code and to see how it could call a table without having to deal with connection object ,statement,etc...

    PS: I would like to see java code and
    to see how it could call a table without
    having to deal with connection
    object ,statement,etc...A Java Stored Procedure still uses JDBC to talk to the database just like on the client. The difference is that instead of making a remote connection (from client to server), your connection is local and is obtained via the url
    DriverManager.getConnection("oracle:jdbc:kprb:@");
    If you don't want to use a Connection, Statement, Resultset, etc, you may wish to use PL/SQL. One of the advantages of Java Stored Procedures is it uses the same JDBC calls as you do on the client, so it makes it easier to move code from client, to app server, to database tier.
    Hope this clears things up a bit,
    Rob
    null

  • A question about a method with generic bounded type parameter

    Hello everybody,
    Sorry, if I ask a question which seems basic, but
    I'm new to generic types. My problem is about a method
    with a bounded type parameter. Consider the following
    situation:
    abstract class A{     }
    class B extends A{     }
    abstract class C
         public abstract <T extends A>  T  someMethod();
    public class Test extends C
         public <T extends A>  T  someMethod()
              return new B();
    }What I want to do inside the method someMethod in the class Test, is to
    return an instance of the class B.
    Normally, I'm supposed to be able to do that, because an instance of
    B is also an instance of A (because B extends A).
    However I cannot compile this program, and here is the error message:
    Test.java:16: incompatible types
    found   : B
    required: T
                    return new B();
                           ^
    1 errorany idea?
    many thanks,

    Hello again,
    First of all, thank you very much for all the answers. After I posted the comment, I worked on the program
    and I understood that in fact, as spoon_ says the only returned value can be null.
    I'm agree that I asked you a very strange (and a bit stupid) question. Actually, during recent months,
    I have been working with cryptography API Core in Java. I understood that there are classes and
    interfaces for defining keys and key factories specification, such as KeySpec (interface) and
    KeyFactorySpi (abstract class). I wanted to have some experience with these classes in order to
    understand them better. So I created a class implementing the interface KeySpec, following by a
    corresponding Key subclass (with some XOR algorithm that I defined myself) and everything was
    compiled (JDK 1.6) and worked perfectly. Except that, when I wanted to implement a factory spi
    for my classes, I saw for the first time this strange method header:
    protected abstract <T extends KeySpec> T engineGetKeySpec
    (Key key, Class<T> keySpec) throws InvalidKeySpecExceptionThat's why yesterday, I gave you a similar example with the classes A, B, ...
    in order to not to open a complicated security discussion but just to explain the ambiguous
    part for me, that is, the use of T generic parameter.
    The abstract class KeyFactorySpi was defined by Sun Microsystem, in order to give to security
    providers, the possibility to implement cryptography services and algorithms according to a given
    RFC (or whatever technical document). The methods in this class are invoked inside the
    KeyFactory class (If you have installed the JDK sources provided by Sun, You can
    verify this, by looking the source code of the KeyFactory class.) So here the T parameter is a
    key specification, that is, a class that implements the interface KeySpec and this class is often
    defined by the provider and not Sun.
    stefan.schulz wrote:
    >
    If you define the method to return some bound T that extends A, you cannot
    return a B, because T would be declared externally at invocation time.
    The definition of T as is does not make sense at all.>
    He is absolutely right about that, but the problem is, as I said, here we are
    talking about the implementation and not the invocation. The implementation is done
    by the provider whereas the invocation is done by Sun in the class KeyFactory.
    So there are completely separated.
    Therefore I wonder, how a provider can finally impelment this method??
    Besides, dannyyates wrote
    >
    Find whoever wrote the signature and shoot them. Then rewrite their code.
    Actually, before you shoot them, ask them what they were trying to achieve that
    is different from my first suggestion!
    >
    As I said, I didn't choose this method header and I'm completely agree
    with your suggestion, the following method header will do the job very well
    protected abstract KeySpec engineGetKeySpec (Key key, KeySpec key_spec)
    throws InvalidKeySpecException and personally I don't see any interest in using a generic bounded parameter T
    in this method header definition.
    Once agin, thanks a lot for the answers.

  • 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.

  • Invoking java methods from C/C++ on the machine with different JREs

    I implemented Windows NT Service instantiating JVM and invoking several java methods. Everything works but I have an issue with running the service on the machine where multiple different versions of JRE have been installed. The service is calling java methods that require JRE 1.3 or later so I wrote the code that is setting system PATH from within the service based on the configuration stored in the external file. The problem is that the service requires jvm.dll to be in the PATH prior lunching it since this library is instantiated through the implicit linking. When I put jvm.dll in the same path as the service binary I can lunch it but JNI_CreateJavaVM fails and returns -1. This happens even if JRE 1.3 is in the system PATH prior lunching the service.
    Everything works if the system PATH contains references to JRE 1.3 and jvm.dll is removed from the service's directory.
    I am looking for an advice on what is the proper way to deal with invoking java methods from the C/C++ executable in the environment with different versions of JRE.
    Thanks, Kris.

    Here's a way I have done what you are asking about:
    What you want to do is make all of your linking happen at runtime, rather than at compile time. This way, you can edit the PATH variable before the jvm.dll gets loaded.
    Following is some code that I used to handle a dll of my own in this manner. You can decide if you want to write a "wrapper" dll, or if you find it simpler to approach the jvm.dll in this way.
    // Define pointer type for DLL entry point.
         typedef void JREPDLL_API (*EXECUTEREQUEST)(char*, Arguments&);
    // Set up path, load dll, and pass everything off to it.
    HINSTANCE javaServer = javaServer = LoadLibrary("jrepdll.dll");
    if (javaServer != NULL) {
    EXECUTEREQUEST executeRequest = (EXECUTEREQUEST)GetProcAddress(javaServer, "ExecuteRequest");
    if (executeRequest != NULL) {
    if (argc == 1)
         // Execute the request.
         executeRequest("-run", args);
    else
         // Execute the request.
         executeRequest("-console", args);
    Here's some code for how to edit the PATH:
              // Edit the PATH environment variable so that we use our private java.
    char *appendPt;
    char *newPath;
    char *path;
              char tmp[_MAX_PATH];
              // Get the current PATH variable setting.
    path = getenv("PATH");
              // Allocate space for an edited path setting.
              if (path != NULL)
                   newPath = (char*)malloc((_MAX_PATH * 2) + strlen(path));
              else
                   newPath = (char*)malloc((_MAX_PATH * 2));
              // Get upper part of path to desired directories.
              strcpy(tmp, filepath);
              appendPt = strstr(tmp, "dbin\\jreplicator");
              appendPt[0] = '\0';
    sprintf(newPath, "PATH=%sjava\\jre1.2.2\\bin;%sjava\\jre1.2.2\\bin\\classic", tmp, tmp);
    // Append the value of the existing PATH environment variable.
    // If there is anything, append it.
    if (path != NULL) {
         strcat(newPath, ";");
         strncat(newPath, path, (sizeof(newPath) - strlen(newPath) - 2));
    // Set new PATH value.
    _putenv(newPath);
              free(newPath);

  • Question about Java's HttpServer: Threading? Backlog?

    Hello,
    I have two questions about Java's HttpServer (com.sun.net.httpserver). From the JavaDoc:
    >
    Management of threads can be done external to this object by providing a Executor object. If none is provided a default implementation is used.
    >
    How can I get information about the default implementation in 1.6.0_13? Do you know the behavior? From my observations, the default implementation uses no Threads, meaning every request is handled in the same Thread, this results in handling the requests to the HttpServer one after another.
    Is this right?
    The second question is about this, also from the JavaDoc:
    >
    When binding to an address and port number, the application can also specify an integer backlog parameter. This represents the maximum number of incoming TCP connections which the system will queue internally. [...]
    >
    When setting the backlog to -1, it uses the systems default backlog. How can I determine the systems default backlog? Can some lines of Java code reveal it (there is no getBeacklog() method)? Or is it up to the Operating System (we use Redhat Linux)?
    Thanks a lot for your help!
    Regards,
    Timo

    How can I determine the systems default backlog?You can't. There is no API for that even at the C level.
    Can some lines of Java code reveal itNo.
    Or is it up to the Operating System (we use Redhat Linux)?Yes. Linux provides a large default. It seems to be at least 50 on most platforms. This is not something you should be worrying about.

  • Rhino calling overloaded Java methods with Array parameters

    Has anyone had any problems writing JavaScript code that calls overloaded Java methods?
    I have two Java defined methods that differ in the arguments, one takes a string the other takes an array of strings. The problem is calling Java methods within the JavaScript always calls the method with the String argument...
    /* Java Code Here */
    public void function(String s) { /* Function A */ }
    public void function(String[] sa) { /* Function B */ }
    /* JavaScript  Code Here */
    param = java.lang.reflect.Array.newInstance(java.lang.String, 2);
    param[0] = "test";
    param[1] = "test2";
    stringParam = "test3";
    /* Both function calls below end up calling the Function A from above */
    function(param);
    function(stringParam);PS...in case you're not familiar with Rhino,
    It is a mozilla package that embeds a JavaScript interpreter within a Java application...
    http://www.mozilla.org/rhino/

    haha...I can't even find my other thread :(
    Sorry about the double post...I'll go look for my other thread now

  • About calling method with arguments

    Hi,
    I have a problem about calling method using reflection. my method is like follows:
    public myMethod(Integer var1, MyObject mobj) {
    I've tried to call the method using the following code,
    Class[] parameterTypes = new Class[] {Integer.class, MyObject.class};
    Object[] arguments = new Object[] {new Integer(2), mobj};
    Method met=cl.getMethod("myMethod", parameterTypes);
    But the in the last line NoSuchMethodException is thrown.
    How can I send the reference of MyObject to myMethod()?
    Thanx
    rony

    Should work ok:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class Test {
         static class MyObject {}
         public static void main(String[] args) throws Exception {
              Class c = Test.class;
              Class[] parameterTypes = new Class[] {Integer.class, MyObject.class};                              
              try {
                   Object[] arguments = new Object[] {new Integer(2), new MyObject()};
                   Method met = c.getMethod("myMethod", parameterTypes);
                   met.invoke(new Test(), arguments);
              } catch (NoSuchMethodException e) {
                   System.out.println(e);
              } catch (IllegalAccessException e) {
                     System.out.println(e);
              } catch (InvocationTargetException e) {
                   System.out.println(e);
         public void myMethod(Integer var1, MyObject mobj) {
              System.out.println("myMethod");
    }

  • URGENT !!!! I know nothing about java .... ;o)

    Hi all,
    here is my problem, I am working on a demo for a customer, I am business consultant and I know nothing about java and I have noone next to give a hand, so please help.
    I integrated a content in a Learning Management System. When launching this content in the LMS, an applet is created. I get a first page where I have to chose an option. When clicking on any of the options, I get nothing. On my java console, I can read this :
    java.lang.NoSuchMethodError: javax.swing.UIManager.c()Ljava/lang/String;
         at com.cbt.jasmine.Jasmine.Jasmine.b([DashoPro-V1.32-013000])
         at com.cbt.jasmine.Jasmine.JasmineApplet.run([DashoPro-V1.32-013000])
         at java.lang.Thread.run(Unknown Source)
    What can I do to make this ******* content work.
    Many thanks for your answers.
    XToff.

    First of all, nothing is urgent to us, only to you.
    Second, the error is clearly stated being NoSuchMethodError i.e. the program is trying to call a method that hasn't been for some reason included in the program.
    Third, I have no idea what Learning Management System is (and I'm not the only one).
    Fourth, why did you put "Re: URGENT !!!! I know nothing about java .... ;o)" as the topic instead of "Learning Management System"?

  • How to make plsql parser around java method

    can someone tell me how can i move Jdeveloper java method into oracle DB (how to make plsql parser around java method). Is this possible becouse in google i can not find any good example how to make this.

    Hi,
    I think you are talking about Java Stored Procedure (?)
    Look here, http://download.oracle.com/docs/cd/E11882_01/java.112/e10588/toc.htm
    Regards
    Peter

  • Is there anyone using Java Methods interface of IREP in his application

    Hello everyone,
    Are you using Java Methods interface of IREP in your application?
    Nowadays I am trying to using Java Methods in my application. But I'm puzzled how to get the interface jar files that the Java Methods would import. It seems that Oracle doesn't provide such interface jar files for all Java Methods shipped in IREP. How do you do with this?
    If you have some experience about using Java Methods in application, hope to hear your voice. Thanks in advance.

    Hi friend,
    Thanks for you update.
    I'm referring to Java Methods that can be called directly by applications not Java Service Interface. These are two different kinds of IREP interfaces. In Oracle Integration Repository User's Guide, there aren't much guidance about how to use Java Methods.
    I appreciate you can help me further.

  • About Java 2 opaque font color question, help needed!

    About Java 2 opaque font color question, help needed!
    I was trying to test opaque font (the string has a foreground color and a background color), but i can't find the method for doing that.
    i can change foreground by Graphics2D.setPaint(Color.black).
    Anybody know how to change the background of the string?
    Thanks!

    Hi. The way I'd do it would be to use the font metrics to find the length of a string and draw a rectangle and then drawstring over the rectangle. If you want an example, I can post it although I suspect theres a better way.

  • Access from Java method

    Hi,
    I'm begginer in Flex and I have question about Java and Flex cooperation. I would like to create controllers and model in Java, and use Flex as a view. As you know sometimes controllers need to change something in view.
    Is there any posibility to change components properties directly from Java code?
    For instance - in my .mxml file I have label and button. After click on button I call Java method which realize my request. Is there any simple way to set label text directly from this method?

    You need setup middleware called BlazeDS and deploy your java app into it. Flex and Java can work together by BlazeDS.

  • Java method in my user interface

    how do i use my java method in my user interface i what this method to be used when i click the login button
    public void PerformSdmsLogon(String userid ,String pwd ) {
    callPerformSdmsLogon("SMS_FORM_TO_ADf.perform_sdms_logon(?,?)",
    new Object[]{userid,pwd,});
    }

    hi Tshifhiwa
    Tshifhiwa wrote:
    how do i use my java method in my user interface i what this method to be used when i click the login button ...You should really provide more information about what your are trying to do, your use-case, and also which version of JDeveloper you are using, which technoligy you are trying to use, which documentation (or examples) you are using.
    Without that you should not be expecting a useful answer to your question.
    (see also https://forums.oracle.com/forums/ann.jspa?annID=56 )
    (see also my reply at Re: how to pass method )
    regards
    Jan Vervecken

  • Query object java method issue

    MyUsernameQuery['userNames'].indexOf('tomjones') will find
    the tomjones
    value in the query.
    BUT:
    MyUsernameQuery['id'].indexOf(99) won't find the numeric
    index value, even
    though it's in the record set.
    BUT WAIT, THERE'S MORE:
    If I manually build a query object with integer values and
    try a similar
    search for the numeric id value,it finds it!
    What's up with that?
    If it was a casting issue, why would it find it in the
    manually built object
    and NOT in the query object?
    I tried casting the integer as a string but no luck.
    I'm in over my head with these methods. Any help much
    appreciated.
    Cheers,
    Lossed
    __when the only tool you have is a hammer, everything looks
    like a nail __

    I should point out that the relative processing speeds are
    dependant upon
    the size of the recordset and position in that recordset of
    the value being
    searching for.
    "Lossed" <[email protected]> wrote in message
    news:eucai4$lhj$[email protected]..
    > It was indeed the casting.
    > I had to cast it as 'long'.
    > There are other ways to find if the value exists:
    > convert column array to list and listfindnocase(), Q of
    Q, loop over
    > query. I was trying to find the fastest. the underlying
    java indexOf()
    > method seems to leave the others in it's dust :).
    >
    > "cf_dev2" <[email protected]> wrote in
    message
    > news:euc51t$epr$[email protected]..
    >>> I'm in over my head with these methods
    >>
    >> Doesn't answer your question, but is indexOf()
    really the only way to get
    >> the
    >> job done? Just wondering if there is an easier way.
    >>
    >> The undocumented stuff is neat, but the java methods
    tend to be stricter
    >> about
    >> object type and case than many of the standard CF
    functions. Two things
    >> may
    >> appear the same but that doesn't mean they are the
    same to java. It can
    >> trip
    >> you up ;)
    >>
    >> That could be the problem with your number column.
    You didn't mention the
    >> column type but some numeric data types don't map to
    a java integer. For
    >> example a biginteger column might map to a java
    long. In which case
    >> searching
    >> for an integer wouldn't work. So it could still be a
    casting
    >> problem
    >>
    >>
    >
    >

Maybe you are looking for