How to return a String in main() [IBM iSeries]

Hei,
gotta question:
How do I return a String on the exit of a Java-Application?
public static String main(String[] args) {
        return aString;
}is "illegal" but I need to do something like that.
What I want to do is to start a java app in a cl on the iSeries (no problem) and fill a variable with the result (the problem)
Big Thx,
LoCal

System.out.println("This is my return String");
then capture the output?

Similar Messages

  • How to return a String

    i have a program that needs to return a String (or a variable that holds test). String is not a return type variable so how do i return a string-like variable (or object). I tried returning a Vector but it doesn'w work the same problem ocurs. Vector is not a reurn type variable (technicly it is not really a variable ata all). So how do is do it.
    Thank you for the help
    Also is there a book i can buy that can help me study for the Java core technology exam (CX-310-055). Is there any material i need to know that i could study from a book that i can buy or some other resource that is now so expensive as taking a java certification class?
    Thank you again

    -- well, you can try this book: Java 2 Programmer Exam Cram 2[b\                                                                                                                                                                                           

  • How to return a string or a comment through ODI os command

    Hi,
    Is there any way so to return any string through odi os command.
    I want to return that error back through odi operator.
    Thanks

    I dont think so. You can modify your script file so that in case of any error it will write a flag (your string values) to another temp file (temp.txt)
    Then read the file via jython. If flag =1 (or your req values) then there is some error in your script. Now Raise error in odi which print the string in operator.
    Thanks.
    Bhabani
    http://dwteam.in

  • How to return a string in chronological order?

    I have a string called schedule, for example:
    schedule = "^14%Paul's house?Group Meeting\n^9%Nutty Professor's Office?Office Hours\n^12%MegaBits?Lunch"
    After breaking it up using StringTokenizer, how do I return it into chronological order?
    Return the schedule for each day of the week as a String with the appointments listed in chronological order, starting with those for the first day of the week and ending with those for the last day of the week.
    The String should have the following format
    Sunday:
    ^14%Paul's house?Group Meeting
    Monday:
    ^9%Nutty Professor's Office?Office Hours
    Tuesday:
    ^12%MegaBits?Lunch
    Wednesday:
    xxx
    Thursday:
    xxx
    Friday:
    xxx
    Saturday:
    xxx
    xxx is the String representation of the schedule for each day. There should be no newline after the last schedule.
    Note: if there are no appointments scheduled for a certain day, then that day should not be included in the String. (For example, if there are no appointments scheduled on Tuesday then:
    Tuesday:
    xxx
    should not be included.)

    Well, then,
    i would assume you need to keep 7 variables, that hold the 7 values of the days,
    then append the values together in the natural order using +

  • How to display subvi string to main FP by using global variable??

    Attach with my vi's here.
    Any help here.
    Thanks in advance.
    regards,
    Simon
    Attachments:
    test.vi ‏15 KB
    subvi.vi ‏31 KB
    Global.vi ‏5 KB

    You could add an independent while loop in the main VI that reads the global every second (or so) and displays it in the indicator.
    (Still, there are probably better ways to do all this ...)
    LabVIEW Champion . Do more with less code and in less time .

  • Returning the string from the SimpleDateFormat

    Hi guys,
    Can someone tell me how to return the string from the SimpleDateFormat?
    I've created the method to do this, but i don't know the exact code to use. Here's my code so far...
        public String convert (Calendar gc)
            String s = convert(gc);
            return // I need to return the s here, but don't know how to code it.
        }BTW, i've already wrote the code for the SimpleDateFormat (so if you want me post that, i will).

    DrLaszloJamf wrote:
    LevelSix wrote:
    DrLaszloJamf wrote:
    No.Can you tell me what it is, because i've went through the API and i don't know.
    Have you looked for a tutorial: [http://java.sun.com/docs/books/tutorial/i18n/format/dateintro.html]
    Thanks a lot DrLaszloJamf, this is useful.
    DrClap wrote:
    Nope. Suppose you were on a construction site and the foreman told you to move a pile of concrete blocks from a truck into the building. What do you suppose would happen if you asked the foreman what a concrete block was, and where the building was, and whether you should drive the truck into the street, and then you tried to pick up the whole pile all at once, and then you asked if you could kick the blocks like footballs? This is what you're doing here. You'd be fired from the construction site within half an hour.Sir...

  • How to transfer a string from sub sequence to main sequence

    Hi,
    How to transfer a string from sub sequence to main sequence, My main sequence has included a sub sequence, the sub sequence is return a string value after running done, I need to get this string value from sub sequence to main sequence, I check the defined that look like seem the two
    sequence have themself local variable,but I don't know how to defined a globe variable to cover main sequence and sub sequence like VC++'s Main App ,Please kindly help me,thanks in advance...

    Hi,
    I hope this small example will help you.
    Regards
    Ray Farmer
    Regards
    Ray Farmer
    Attachments:
    Sequence File1.seq ‏36 KB

  • How do I open a .nrl extension in firefox, currently it returns a string of text instead of opening the file with the default program.

    When I click on a .nrl file extension (belongs to Autonomy I-Manage Software) it returns a string of code (what is in the shortcut link) instead of following the link and returning the document. Is there a way to tell Forefox connect to the document that the shortcut is linked to? The .nrl file extension belongs to a piece of software called FileSite (document management system).

    '''Adding download actions''' is the relevant section of that article for your situation.
    Is the *.nrl file on a website or already saved to your PC?
    If it is on a website, the server may not be sending the appropriate Mime-Type telling Firefox how that file is to be handled - ''"Content-Disposition"''.
    Can you give us the URL of the webpage where you have this problem? <br />
    So we can see first hand what the issue is.

  • How to print a string with out using main method??

    how to print a string with out using main method??
    if we can tell me with example?
    thanks in adavance
    raja

    Hi,
    actually there's none. The UITableView class needs to "know" the tableView's height so either it can calc <number of rows> times <row height> or it has to sum the height of each single row.
    If the row which needs to be of different size always is the first or the last row you can user a tableHeader or tableFoot view.
    Regards
    Dirk

  • How to send a string to CVI .c and get string return through TestStand sequence?

    Hi, I am using TestStand 3.1 and I have the StringConverter.c with CVI 8.0 with the function:
    char * string_concat_2 (char* str1,char* str2)
     char * str_ret;
     str_ret = calloc(200, sizeof(char*));
     str_ret = strcat (str_ret, str1);
     str_ret = strcat (str_ret, str2);
     return str_ret;
    I would like to use it  through Teststand, so I add a sequence using 'StringValueTest'. I Spectify Module CVI &  link to StringConverter.c and type in Function Name: char * string_concat_2 (char* str1,char* str2)
    1. How I define to send the string1 ("Hello") & string2 ("World") to the Module?
    2. How I define to string return ("HelloWorld" from the Module?
    Thanks

    Hi plit string,
    You will need to have a parameter passed by reference to return the
    string.  To do this, use a "C String Buffer" instead of a "C String
    (const)" parameter type.  There is documentation on this in TestStand
    Help.  Here is a quote from there:
    "When using string parameters, use the C String Buffer or Unicode
    String Buffer type if you want the function to be able to change the contents of
    the argument in TestStand. Use the C String or Unicode String type if the DLL
    function does not modify the argument. You can pass a literal string, a
    TestStand string property, or an expression that evaluates to a string as the
    value of a string parameter."
    Gavin Fox
    Systems Software
    National Instruments

  • 2 Threads issues. How to return data from a thread located in other class

    I have 2 questions.
    This is the context. From main I start one thread that does a little job then starts another thread and waits for it to end to continue.
    1) The last started thread needs to return a string to the Thread started from main. How can I accomplish that, because I read that I cannot use
    synchronized methods outside different classes (and the threads belongs to different classes).
    2) From the main thread I start the Second Thread located in another class like this ClassName obj = new ClassName(arg); obj.start(); obj.join()
    Is that correct for waiting for the created thread to finish ?

    1) The last started thread needs to return a string to the Thread started from main. How can I accomplish that, because I read that I cannot use
    synchronized methods outside different classes (and the threads belongs to different classes).Threads do not "belong" to classes. Class code executes in a particular thread. The class instances exist as long as something, somewhere, holds a strong reference to them.
    So when you start a new thread, hold a strong reference to the object being executed by that thread. When the thread is done, retrieve your data from that object.
    Even better, don't subclass Thread to create your objects. Instead, implement Callable, and use a ThreadPoolExecutor to execute it.

  • How to return more than one object from SwingWorker

    I am using a SwingWorker to call 3 different methods of another class (data fetch class). Each of these 3 methods returns a String array. I am able to get the first array outside the thread code using the get() method of the SwingWorker class,
    final String tmpOrdNum = OrderNum;
    SwingWorker worker = new SwingWorker() {
         DATA_FETCH_TO_ARRAY data_fetch = new DATA_FETCH_TO_ARRAY(tmpOrdNum);
         public Object construct(){
              String [] orderArr = data_fetch.getHeaderArray();
              //String [] detailArr = data_fetch.getDetailArray();
              //String [] storeArr = data_fetch.getStoreArray();                    
              return orderArr;
         //Runs on the event-dispatching thread.
         public void finished(){     }
    worker.start() ;
    String[] testArr = (String[])worker.get();      //gets the header array
    /* HOW DO I GET THE DETAIL AND STORE ARRAYS HERE?*/I want to be able to call the other 2 methods of the data fetch class - getDetailArray() and getStoreArray() shown commented in the above code one by one.
    Can someone please suggest a way of doing this? Thank you.

    Return String[][] from construct method.
    Here is an example (observe test method):
    import java.util.*;
    public class ArrayTest{
         public static void main(String[] args){
              String[][] result=(String[][])new ArrayTest().test();          
              System.out.println("result1: "+Arrays.toString(result[0]));
              System.out.println("result2: "+Arrays.toString(result[1]));
              System.out.println("result3: "+Arrays.toString(result[2]));
         public Object test(){
              String[] str1={"A","B","C"};
              String[] str2={"M","N","O"};
              String[] str3={"X","Y","Z"};          
              String[][] out=new String[3][];
              out[0]=str1;
              out[1]=str2;
              out[2]=str3;
              return out;
    }Thanks,
    Mrityunjoy

  • How to convert a String to an Icon

    Hello,
    I'm trying to figure out how to convert a String (specifically one letter) to an Icon for a JTree. The program I am working on uses .png files for the icons at the moment, with each .png being a single uppercase letter. However, recent discussion has us wanting to change to something more dynamic, since we anticipate needing new letters in the near future.
    My task is to modify the current codebase so that the Icons used to identify nodes in the tree are created from a Font within code, rather than reading in .png files. I have done some experimenting with creating a Label with just that String, setting the font and trying to extract the image using calls like createImage(int width, int height) and so on, but so far to no avail.
    If I could figure out how to at least convert the String to an image, I could probably make it work (since I can play around with creating an ImageIcon with that image). Thanks in advance for any help.
    Allan

    Here is some quick and dirty code:
    import java.awt.*;
    import javax.swing.*;
    public class BasicIcon implements Icon {
        private String text;
        public BasicIcon(String text) {
            this.text = text;
        public int getIconWidth() {
            return 16;
        public int getIconHeight() {
            return 16;
        public void paintIcon(Component c, Graphics g,  int x, int y) {
            Color old = g.getColor();
            g.setColor(c.getForeground());
            g.drawString(text, x, y+13);
            g.setColor(old);
        public static void main(String[] args) {
            JPanel cp = new JPanel();
            for (char ch = 'A'; ch < 'F'; ++ch) {
                cp.add(new JButton("letter " + ch, new BasicIcon(String.valueOf(ch))));
            JFrame f = new JFrame("BasicIcon");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }One thing that could be improved is the vertical positioning of the letter in the Icon.
    The x,y values passed into paintIcon are the upper-left hand corner of the icon,
    but the y value needed by drawString is the position of the String's baseline.
    To do it right, use one of Font's getLineMetrics methods and play around with ascent.

  • How to return jolt connection back to the joltpool?

    hi
    I used following codes to get joltconnection pool:
    SessionPool sessionPool = sessionPoolManager.getSessionPool(poolName);
         DataSet request = new DataSet(requestString.length()*2);
         request.setValue("STRING", requestString);
         Result result = sessionPool.call(serviceName, request, null);
         return (String) result.getValue("STRING", null);
    my question is : how to return jolt connection back to the joltpool? do I need
    to do that?
    when I used jdbc connection pool, I used conn.close() to return
    to jdbc connection pool. Is there any method like "close()" in
    jdbc connection?
    Wei Jiang

    Hi,
    The below is the simple source code using Pool which it is extracted from
    BEA's support web site.
    and it is helpful.
    The Pool doesn't need to return jolt connection back to the joltpool.
    because it is done by Pool Manager automatically.
    import bea.jolt.*;
    import bea.jolt.pool.*;
    public class Pho2 {
    public static void main(String argv[])
    try
    String[] adresses = new String[1];
    adresses[0] = "//aglaia:7040";
    // creation du manager et du pool par defaut
    SessionPoolManager sessionPoolManager = new SessionPoolManager();
    int i = sessionPoolManager.createSessionPool(adresses, null, 1, 3, new
    UserInfo(), null);
    SessionPool sessionPool = sessionPoolManager.getSessionPool(null);
    DataSet dataset = new DataSet();
    Result result=null;
    dataset.setValue("rhaine","coucou");
    try
    result = sessionPool.call("TOUPPER", dataset, null);
    catch(Exception Ex)
    System.out.println("session");
    Ex.printStackTrace();
    System.out.println("dataset="+dataset);
    System.out.println("result ="+result);
    System.out.println("ApplicationCode="+(new
    Integer(result.getApplicationCode())).toString());
    catch(Exception Ex)
    System.out.println(Ex.getMessage());
    Hope this helps.
    Mr, Ko.
    "wei jiang" <[email protected]> wrote in message
    news:[email protected]..
    >
    hi
    I used following codes to get joltconnection pool:
    SessionPool sessionPool = sessionPoolManager.getSessionPool(poolName);
    DataSet request = new DataSet(requestString.length()*2);
    request.setValue("STRING", requestString);
    Result result = sessionPool.call(serviceName, request, null);
    return (String) result.getValue("STRING", null);
    my question is : how to return jolt connection back to the joltpool? do Ineed
    to do that?
    when I used jdbc connection pool, I used conn.close() to return
    to jdbc connection pool. Is there any method like "close()" in
    jdbc connection?
    Wei Jiang

  • JAVA&SOAP:how to return a complex object( the object has an object within)

    Lets say my Complex object is :
    public class PersonWithAddress {
    private String name;
    private int ssn ;
    private Address add;
    PersonWithAddress() {
    name="Gagan Tandon" ;
    ssn =1111;
    add = new Address("1113","WestPlum Street");
    public String getName() {
    return name;
    public int getSSN() {
    return ssn;
    public Address getAddress() {
    return add;
    This complex object has Address object embedded in it.
    public class Address {
    private String house;
    private String street;
    public Address (String myHouse,String myStreet) {
    house = myHouse;
    street = myStreet;
    public String getHouse() {
    return house;
    public String getStreet() {
    return street;
    My deployment Descriptor is as following: check the mappings part.
    <isd:service xmlns:isd=
    "http://xml.apache.org/xml-soap/deployment"
    id="urn:xml-soap-person-demo">
    <isd:provider type="java"
    scope="Application"
    methods="getPersonWithAddress">
    <isd:java class="PersonServer"/>
    </isd:provider>
    <isd:faultListener>
    org.apache.soap.server.DOMFaultListener
    </isd:faultListener>
    <isd:mappings>
    <isd:map
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:x="urn:xml-soap-person-demo" qname="x:PersonWithAddress"
    javaType="PersonWithAddress"
    java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
    xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
    <isd:map
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:x="urn:xml-soap-person-demo" qname="x:Address"
    javaType="Address"
    java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
    xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
    </isd:mappings>
    </isd:service>
    And in my SOAPRPC code at client end calls the following: check the mappingregistry code...
    String serverHost = "http://localhost:8082/soap/servlet/rpcrouter";
    SOAPMappingRegistry smr = new SOAPMappingRegistry();
    Parameter p= null;
    try {
    System.out.println("here 0");
    Response r=null;
    Call c=new Call();
    Vector parameters = new Vector();
    System.out.println("here 1");
    c.setTargetObjectURI ("urn:xml-soap-person-demo");
    c.setMethodName ("getPersonWithAddress");
    System.out.println("here 3");
    c.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    // parameters.addElement (new Parameter("name", String.class, "Web Services Client", null));
    // c.setParams (parameters);
    c.setSOAPMappingRegistry(smr);
    BeanSerializer beanSer = new BeanSerializer();
    smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("urn:xml-soap-person-demo","Address"),Address.class,beanSer,beanSer);
    smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("urn:xml-soap-person-demo","PersonWithAddress"),PersonWithAddress.class,beanSer,beanSer);
    try
    System.out.println("here 4");
    r = c.invoke ( new URL(serverHost), "" );
    // org.apache.soap.SOAPException can be thrown
    catch ( Exception e )
    e.printStackTrace();
    // Check the response.
    if (r.generatedFault ()) {
    Fault f = r.getFault();
    System.out.println ("Error Occurred: ");
    System.out.println (" Fault Code = " + f.getFaultCode());
    System.out.println (" Fault String = " + f.getFaultString());
    // return f.getFaultString();
    // return new String("gagan");
    return null;
    else {
    System.out.println("here 5");
    p = r.getReturnValue();
    System.out.println("here 6");
    // System.out.println( (String)greeting.getValue() );
    System.out.println("SSN: " + ((PersonWithAddress)p.getValue()).getSSN());
    return (PersonWithAddress) p.getValue();
    catch( Exception e ){
    e.printStackTrace();
    // finally {
    // return null;// String("not OK");
    if (p==null)
    return null;
    else
    return (PersonWithAddress) p.getValue();
    When running this code..
    The following error is thrown.
    System.out.println("here 4") is printed.
    [SOAPException: faultCode=SOAP-ENV:Client; msg=Unable to instantiate 'PersonWithAddress': Class org.apache.soap.encoding.soapenc.BeanSerializer can not access a member of class PersonWithAddress with modifiers ""; targetException=java.lang.IllegalArgumentException: Unable to instantiate 'PersonWithAddress': Class org.apache.soap.encoding.soapenc.BeanSerializer can not access a member of class PersonWithAddress with modifiers ""]
    at org.apache.soap.rpc.Call.invoke(Call.java:294)
    at PersonClient.getPersonWithAddress(PersonClient.java:92)
    at PersonClient.<init>(PersonClient.java:11)
    at PersonClient.main(PersonClient.java:20)
    java.lang.NullPointerException
    at PersonClient.getPersonWithAddress(PersonClient.java:96)
    at PersonClient.<init>(PersonClient.java:11)
    at PersonClient.main(PersonClient.java:20)
    I am here 1
    Exception in thread "main" java.lang.NullPointerException
    at PersonClient.<init>(PersonClient.java:13)
    at PersonClient.main(PersonClient.java:20)
    What could be the problem..? Is there any info on net how could i pass complex objects of this type in Java through SOAP RPC.
    GAGAN

    Have you managed to sole the problem ? I have got similar one...
    [SOAPException: faultCode=SOAP-ENV:Client; msg=Unable to instantiate 'auction.common.Property': auction/common/Property]
         at proxy.soap.AuctionHistoryProxy.addAuctionProperty(AuctionHistoryProxy.java:515)
         at java.lang.reflect.Method.invoke(Native Method)
    (...)

Maybe you are looking for