Using a function from static context..

Well I have a command line app; and it has a public static void main. Now, I made a function that writes to a file, and tried calling it from the main section, and it got mad saying I can't call it from static context. Anyway to allow it to be called from both static and non static contexts?

otherwise create object of the class, from that object you can call a method

Similar Messages

  • Impossible to use SAPGETDATA function from an intermediary level of a hierarchy with a cell reference.

    Hi Gurus,
    It is impossible to use SAPGETDATA function from an intermediary level
    of a hierarchy with a cell reference.
    When I open completely a hierarchy node I manage to get the bottom level
    using a cell reference.
    But I cannot do the same thing from a level above.
    I attach screenshots.
    Best regards,
    Thierry Chiret

    Hello,
    I find the soluce :
    Regards,
    Thierry

  • Cannot use this in a static context

    I have a static method in which I am trying to use a logging class. I get an error that says "Cannot use this in a static context" when I compile the following code.
    Log log = LogFactory.getLog(this.getClass());What's the problem and how do I get around it?

    1) What's the problem.
    The error states the problem concisely. You are trying to use this[b] to get the class. You can't do this in a static method.
    2) How do I get around it...
    Instead of typing this.getClass() you type <CLASS_NAME>.classwhere CLASS_NAME is the name of the class the static method is in.

  • Non-static variable from static context?

    Hi,
    I've created a program using swing components
    and I've set up a addActionListener to a button,
    button.addActionListener(this);
    when try and compile I get the following error:
    non-static variable this cannot be referenced from a
    static context
    button.addActionListener(this);
    I've checked site and my notes I don't seem to have
    done anything different from programs that have compiled
    in the past.
    I'm currently doing a programming course so I'm fairly
    new to Java, try not to get to advanced on me :)
    Thx in advance for any help.
    Chris

    Well what is declared static? If I remeber right this error means that you have a static method that is trying to access data it does not have access to. Static methods cannot access data that is intance data because they do not exist in the instance (not 100% sure about this but I believe it is true, at the very least I know they do not have access to any non-static data). Post some more of your code like where you declare this (like class def) and where you set up the button.

  • Generating Dynamic form from static context.

    Hi All
    I have  static context node structure
    Section  (Node)
          QuestionText  (Attribute)
           AnsText  (Attribute)
    I have populated the values in this node from an RFC in my code .
    Now i need to create a form dynamically with QuestionText as labels and AnsText as input fields.
    I have written the following code
    for(int i = 0; i< wdContext.nodeSection().getSize; i++)
    IWDInputField  inp_Ans = (IWDInputField)view.createElement(IWDInputField.class,"ID"+i);
    IWDAttributeInfo ansAtrib = wdContext.nodeSection().getNodeInfo().getAttribute("AnsText");
    inp_Ans.bindValue(ansAtrib);
    This way i have bound  a single attribute to all inputfields.
    So the value in the first element of AnsText appears in all inputfields.
    In case of tables it works fine but i need to create the form.
    Kindly help me in solving the issue.
    Regards
    Sonal

    It is not possible to bind UI elements against node elements, only inside context-driven UI elements like Table, RowRepeater etc.
    What you can do is
    - use a RowRepeater, or
    - create separate context attributes instead of node elements and bind the programmatically created Label and InputField elements to these attributes
    Armin

  • XSLT using Java function from graphical mapping (RFClookup)

    Hi,
    I was wondering if it is possible to use the standard Java functions of the graphical mapping (RFCLookup, Datetrans, ...) or from my own UDF inside an xslt mapping. Does anyone have every tried this or is an example available ?
    Regards Bernd

    Hi Bernd,
    here you can find an example how to use RFC lookup from an XSLT Mapping:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14?quicklink=index&overridelayout=true
    Is this what you're looking for?
    Regards,
    Gábor

  • Use of functions in static block

    Hello,
    I have this app containing a static {} block. The reason it's there is to 1) provide a splash screen 2) have input dialog to process input string and check if it's valid in order to load app or not.
    In pseudocode it's like this:
    1 - get input string with showInputDialog()
    2 - check for the input string validity (a valid string is with prefix A-, C- or S-)
    3 - if string is valid, load the app
    4 - if string is not valid, proceed to step 1.
    As you may already see, there is going to be a lot of code (with if-else statements) to check for A-, C- and S- prefixed because I am using indexOf() function which takes only one parameter.
    I am considering a way to somehow check recursively, but for this I think I'll need a function to call indexOf() with A-, C-, S- and assess validity for each case.
    My question is, is there a way in the static block to have a function? Or can somebody please recommend an efficient approach to checking a string validity with different possibilities inside a static block as in my case, to avoid lots of if-else statements?
    P.S. My apologies for initially posting this thread in wrong section.
    Thank you!
    Victor.

    DrClap wrote:
    What's a function? And why are you particularly concerned about doing those things in a static initializer as opposed to in some other place?Hi,
    Sorry, I'm still thinking c++. I meant method. Something like of the form:
    static
    boolean valid = false;
    while string is not valid
    stringfrominput = showInputDialog();   
    //determine if string is valid
    valid = checkvalid(stringfrominput)
    //if possible to have
    boolean checkvalid(stringfrominput)
    recursively process stringfrom input based on A-, S-, or C- prefixes
    return boolean value
    }I have a jar app. It is Windows-based and runs as a TrayIcon application. If I include this process when class is loaded, this means that the app will be loaded with all its features. But I need to make sure that the app's features will be loaded only if certain conditions are met.
    I am not sure how else to approach this requirement without using static {} block.
    Thank you,
    Victor.

  • Using a function from another file

    Dear friends,
    I have two different java files in one folder. One is sm.java and the other is AVTransmit2.java. The code below describes the create Transmitter function in the AVTransmit2.java file. Now if i would like to use this function in sm.java, how do i do it ? The create transmitter function is shown below. Thank You, Gan.P
    private String createTransmitter() {
    // Cheated. Should have checked the type.
    PushBufferDataSource pbds = (PushBufferDataSource)dataOutput;
    PushBufferStream pbss[] = pbds.getStreams();
    rtpMgrs = new RTPManager[pbss.length];
    SessionAddress localAddr, destAddr;
    InetAddress ipAddr;
    SendStream sendStream;
    int port;
    SourceDescription srcDesList[];
    for (int i = 0; i < pbss.length; i++) {
    try {
    rtpMgrs = RTPManager.newInstance();
    // The local session address will be created on the
    // same port as the the target port. This is necessary
    // if you use AVTransmit2 in conjunction with JMStudio.
    // JMStudio assumes - in a unicast session - that the
    // transmitter transmits from the same port it is receiving
    // on and sends RTCP Receiver Reports back to this port of
    // the transmitting host.
    port = portBase + 2*i;
    ipAddr = InetAddress.getByName(ipAddress);
    localAddr = new SessionAddress(InetAddress.getLocalHost(),
    port);
    destAddr = new SessionAddress(ipAddr, port);
    rtpMgrs.initialize(localAddr);
    rtpMgrs.addTarget(destAddr);
    System.err.println( "Created RTP session: " + ipAddress + " " + port);
    sendStream = rtpMgrs.createSendStream(dataOutput, i);
    sendStream.start();
    } catch (Exception e) {
    return e.getMessage();
    return null;
    }

    Kalani and Bz,
    Thanks for the reply. Now i can call the function ,
    but when i write sendStream.start(); it indicates
    that, its an error. sendStream.start is in that
    function. but i cant call that
    Any idea ?
    thank you
    Gan.PCan you please inform what is the error ?

  • Using PostLVUserEvent function from Labview.dll

    I am trying to use the PostLVuserEvent function from the labview.dll and corresponding extcode.h file.  I have made my own dll using CVI that uses this function.  I then use Labview to call my dll.  My dll compiles fine.  No issues, no errors.  LabView can call my dll function containing the PostLVUserEvent function with no errors.  However, the event number LabView passes my dll is not the same event number I receive so no LabView event is triggered. 
    Has anyone had this issue? 
    We are trying to solve it from the LabView side and the CVI side but cannot seem to get it to work.  The examplesI have found here were compiled using C++ and those seem to work.  I do not know why when I compile my program in C, it creates the dll but does not work.   If I had to guess, i think it's an issue with pointers vs non-pointers.  When the LAbview program selects my function from the dll, it shows the argument PostLVUserEvent as a pointer when in my dll, it is not a pointer PostLVUserEvent....
    Any ideas?
    Thanks in advance. 

    Hello Blue
    Take a look to this one, it was created on C, I think the .c and the .h files will give a good idea, how the function should be implemented. It is important when calling the dll on LabVIEW, to use the std calling convention and run it on the UI thread.
    Regards
    Mart G
    Attachments:
    LabView EventTest.zip ‏1041 KB

  • Outb() and ddi_put8()  functions from user context

    dear all,
    the man pages for both outb() and ddi_put8() say:
    "These functions may be called from user or interrupt context"
    Question: If I want to call them from user context: which library do
    I have to link with my executable ?
    cheers,
    julien

    Hello.
    I think "user context" does not mean calling from an executable file.
    "User context" means that the functions can be called when the driver is called from a system call (e.g. ioctl) in contrast to interrupt service routines which are called by the OS.
    Sparc machines do not allow something like iopl() in Linux while x86 would allow that when writing a special driver for that.
    Martin

  • New to FIOS TV Multi-room DVR - Should I be able to use DVR functions from the other HD STBs?

    We just converted from Directv (three DVRs) to FIOS TV and am hoping I didn't make a huge mistake: The sales agent I spoke to said that the Multi-room DVR (Motorola QIP-7216-1) and non-DVR STB would enable me to get the same features I had with my Directv setup so each user could Stop/Start/Record programming from their own remote. Unless I'm doing something wrong, I can only perform DVR control functions from the real DVR. I can view recorded programming on the non-DVR STBs but pressing record for a live broadcast or trying to select a show to record from the guide doesn't work.
    I have the ActiontecGen2 MOCA connected MI424WR router, three HD STBs (Motorola 7000), one standard definition STB and the DVR.

    Tomd514 wrote:
    We just converted from Directv (three DVRs) to FIOS TV and am hoping I didn't make a huge mistake: The sales agent I spoke to said that the Multi-room DVR (Motorola QIP-7216-1) and non-DVR STB would enable me to get the same features I had with my Directv setup so each user could Stop/Start/Record programming from their own remote. Unless I'm doing something wrong, I can only perform DVR control functions from the real DVR. I can view recorded programming on the non-DVR STBs but pressing record for a live broadcast or trying to select a show to record from the guide doesn't work.
    I have the ActiontecGen2 MOCA connected MI424WR router, three HD STBs (Motorola 7000), one standard definition STB and the DVR.
    As you've found, you can only create recordings from the DVR.  If you want each room to have the ability to schedule recordings, then you need a separate DVR in each room.
    The FiOS Motorola DVRs cannot access recordings stored on other DVRs.
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it.

  • Problem using isChannelSecure() function from SecurityService Interface

    Hi everyone
    I'll appreciate if anyone could tell me what is exactly the properties arguman in
    boolean isChannelSecure(byte properties) function from SecurityService Interface.
    Best Regards
    Shanar

    API?

  • How to use custom functions from Dlls

    I would like to know if there a way to import functions from
    a custom DLL?
    Thanks

    Hi Wardell,
    Did you get any break through on this I was exploring on same.
    Egarly awaiting reply....
    Regards,
    Ankeet Pujara

  • Can't use Export Functionality from form?

    Hi experts,
    I got a problem now, can anyone help me??
    This's my system information:
    APPLICATION: 11.5.10.2
    DATABASE: 9.2.0.6.0
    And the problem is:
    - Open 1 Form
    - File > Export
    - The progress bar update to 100%
    - The browser is opened
    And it suddenly disappear.
    I've checked metalink and see this note: 423261.1 How to Troubleshoot Forms Hanging Using Export Functionality
    I think it's fail in phase 4:
    4) Finally generate the URL, and display the file in the browser window by calling the Forms built-in web.show_document
    But i don't know how to solve this problem. Can anyone show me?
    Thank you so much

    Hi everybody,
    I solved my problem. In my case, it's because tablespace CTXD was not have enough free extent. You can check this note
    Information You Should Upload When Creating an SR for File Export and Attachments      Doc ID:      Note:427964.1
    Hope that helps,

  • Using a Function to Set Context

    I have a report which contains 5 concatenated SQL queries.
    The first query calls a function and sets a context ie. SELECT set_ctx('ORG_ID',500) from DUAL
    The following SQL sets use views which have predicates based on the context.
    1) Within a single report are the SQL statements executed using separate connections to the database? I am not seeing my Context so I'm assuming XMLP splits and calls each within its own Prepared Statement and seperate connection out of the Pool.
    2) If they are, is the only way to set a context safely by use of a <dataTrigger> within a Data Template? and would it need setting For Each piece of SQL that fires within the Template? Or can it be defined just once at the start?
    Thanks in advance for your answers.
    Matt

    Stuart,
    did you try using...
    document.form.<dropdown name>.options[document.form.<dropdown name>.selectedIndex].value ?
    This should ideally fetch you the value of the selected value of the dropdown - only thing is that the dropdown in an autorefresh dropdown by default - this you would have to figure out as to how it can be overridden. Maybe an Onchange event can be written locally on the template overriding the onchange event from SAP...
    Arun

Maybe you are looking for

  • Help with error in icrg 102

    I HAVE THE NEXT ERROR 'UNHANDLED ERROR IN ICRG 102' IN ORACLE FORMS 5.0 WHEN I CREATE A RECORD GROUP WITH THE SENTENCE 'select nombres, to_char(ficha) from abogados order by nombres ' where nombres is data type VARCHAR2 and ficha is NUMBER. TOO I GOT

  • How to acquire more than 32 channels

    ical support if you need further assistance. Ross C National Instruments" This answer has not yet been rated. Rate this answer: parimala on 8/14/2003 commented: "As you are from NI definitely you might be knowing the answer to my question. My questio

  • Import table data in right order to avoid violating foreign key constraints

    Gentlemen I am trying to import table data into an existing 10g schema using datapump import in table mode. However, in order to avoid violating foreign key constraints, the tables must be loaded in a specified order. I tried specifying the order in

  • Never made web site,Not subscribed to MobileMe, where can  publish for free

    I want to start off making a website, a basic one, as its my 1st about a hobby. I was going to use a free online web based one, but thought I have iMac and iLife 08, so why not try iWeb I know its tied into MobileMe, but is there a way to post the si

  • Error while using BAPI for F-47 posting.

    Hi, I am using the BAPI - 'BAPI_ACC_DOCUMENT_POST' to do a Down Payment Request Posting (F-47). Since this is a single line posting, BTE RWBAPI01 was implemented as given in the below link. [Re: BAPI or Function Module for F-47 (Down payment request)