How to change value of instance variable and local variable at run time?

As we can change value at run time using debug mode of Eclipse. I want to do this by using a standalone prgram from where I can change the value of a variable at runtime.
Suppose I have a class, say employee like -
class employee {
public String name;
employee(String name){
this.name = name;
public int showSalary(){
int salary = 10000;
return salary;
public String showName()
return name;
i want to change the value of instance variable "name" and local variable "salary" from a stand alone program?
My standalone program will not use employee class; i mean not creating any instance or extending it. This is being used by any other calss in project.
Can someone tell me how to change these value?
Please help
Regards,
Sujeet Sharma

This is the tutorial You should interest in. According to 'name' field of the class, it's value can be change with reflection. I'm not sure if local variable ('salary') can be changed - rather not.

Similar Messages

  • Default initialisation of member variables and local variables

    I don't understand why member variables are initialized with default values by Java.
    Objects are initialized with "null" and primitives with "0", except boolean, which is initialized with "false".
    If these variables are used locally they are not initialized. The compiler requires them to be initialized by the programer, for example "String s = null".
    Why? What is the use of that difference?
    And why are arrays always initialized with default values, no matter if they are member variables or local variables? For example String[] s = new String[10]; s[0] to s[9] are initialized with "null", no matter if "s" is a local or member variable.
    Can someone please explain that strange difference, why it is used? To me it has no sense.

    Most of the time I have to initialize a local variable
    with "String s = null" in order to use it because
    otherwise the compile would complain. This is a cheap
    little trick, but I think everyone uses it.
    I wouldn't agree with "most of the time". The only cases where it is almost necessary to do that is when the variable should be initialized in a loop or a try-catch statement, and that doesn't happen too often.
    If local variables were initiliazed automatically without a warning it would be a Bad Thing: the compiler could tell when there is a possibility that a variable hasn't been assigned to and prevent manymanymany NullPointerExceptions on run time.
    And you didn't answer me why this principle is not
    used with arrays if it is so useful as you think.
    Possibly it is much more difficult to analyse the situation in the case of arrays; what if values are assigned to the elements in an order that depends on run time properties such as values returned from a random number generator.
    The more special rules one has to remember, the more
    likely one makes errors.I agree, but what is the rule to remember in this case?

  • How to get multiple values in a variable and apply filter at run time

    Hi experts,
    I want to get the deprtment information for an user. User may belongs to many department.
    when user login at run time the filter should be apply for his departments.
    users deprtments chnages frequently so we can't hardcode it.

    Hi,
    Please refer to below post for one of the causes of this error:
    Re: obiee-ebs  data  security integration
    Also, can you check if you are getting NULL values for any rows. This might be the issue too. To verify this add ' and a.BUSINESS_UNIT_CODE is not null' in your query and check the results. Ensure you restart the BI services, clear your cache and then verify your result.
    Thanks

  • How to change Number of test socket in Model option during run-time

    I wanna be able to change the the number of test sockets(in the Model Options menu) during runtime. I have overriden the Prebatch callback and used my own instead. I have a LabView program in my Prebatch where I would select the test script each time before running the batch. I wann be able to also modify the number of test sockets each time before I run the batch again. I tried setting the "Parameters.ModelData.ModelOptions.NumTestSockets" from the Labview program which is in my Prebatch before running each batch, but get into errors. Please help?

    Hello Kumar,
    The Batch process model shipped with TestStand does not handle this scenario, but you can still do this. Attached is a sequence file that utilizes the Batch Model's ProcessCleanup callback to reset the next execution point. It still uses the method of setting the Parameters.ModelOptions.NumTestSockets variable in the PreBatch callback. The change I added was three steps to a different callback (the ProcessCleanup callback):
    Message Popup - prompts Yes or No to continue testing with a new batch size.
    Statement 1 - based on the response to the message popup (via precondition), resets the Batch Model's next step to be executed and the ContinueTesting flag:
    RunState.Root.RunState.StepGroup = "Setup"
    RunState.Root.RunState.NextStepIndex = 0
    RunState.Root.Locals.ModelData.ContinueTesting = True
    Statement 2 - based on the response to the message popup (via precondition), loops to reset each TestSocket's ContinueTesting flag:
    RunState.Root.Locals.ModelData.TestSockets[RunState.LoopIndex].ContinueTesting = True
    These two statement steps force the next step to be executed in the Batch Process Model to be the first step in the "Setup" step group, and reset all necessary flags for the batch itself and the individual TestSockets. I discovered the flags that had to be reset by trial-and-error (that was the time-consuming part).
    You can run continuous batches of the same size you first chose (for as long as you like), but when stop the batch execution this new message popup will prompt (yes/no) whether you want to continue testing with a new batch size. If no, then processing terminates. If yes, then the next two statement steps are run and execution resumes back at the beginning of the Batch Process Model's Setup step group. This forces the ModelOptions callback to be executed again, so your VI (in my example here it's just a Message Popop) can then set NumTestSockets appropriately.
    Thanks for contacting National Instruments!
    David Mc.
    NI Applications Engineering
    Attachments:
    kumar.seq ‏27 KB

  • How to change value of element and update XML file

    Hi
    I have an xml file called test.xml like below
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
         <userName/>
         <viewName/>
    </printing>I want to change value of user name and view name and update test.xml file in my folder
    Anyone has sample code to do so
    Ashish

    Thanx
    i was able to do so, but what i want now is to remove element
    for example
    i have following xml
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
              <firstLineText />
              <firstLineText>|line11</firstLineText>
              <firstLineText>|line12</firstLineText>
    </firstLineTexts>
    </printing>how do i remove all elements fireLineText
    my final output should be
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
    </firstLineTexts>
    </printing>How do i do it using DOM,
    I can create instance of DOM and write it using TransformerFactory
    Ashish

  • How to assign Values to nested table and pass as parameter to procedure?

    How to assign Values to nested table and pass as parameter to procedure?
    Below is the Object and its type
    create or replace type test_object1 as object
    val1 varchar2(50),
    val2 varchar2(50),
         val3 varchar2(50)
    create or replace type test_type1 is table of test_object1;
    create or replace type test_object2 as object
    val1 varchar2(50),
    val2 varchar2(50),
         val3 varchar2(50)
    create or replace type test_type2 is table of test_object2;
    GRANT ALL ON test_object1 TO PUBLIC;
    GRANT ALL ON test_type1 TO PUBLIC;
    GRANT ALL ON test_object2 TO PUBLIC;
    GRANT ALL ON test_type2 TO PUBLIC;
    here is the table made of object type:
    create table test_object_tpe
    sl_num NUMBER,
    description VARCHAR2(100),
    main_val1 test_type1,
    main_val2 test_type2
    NESTED TABLE main_val1 STORE AS tot1
    NESTED TABLE main_val2 STORE AS tot2;
    here is the procedure which inserts values into nested table:
    PROCEDURE INSERT_TEST_DATA(sl_num IN NUMBER,
    description IN VARCHAR2,
    p_main_val1 IN test_type1,
    p_main_val2 IN test_type2
    IS
    BEGIN
    FOR rec in p_main_val1.first..p_main_val1.last
    LOOP
    INSERT INTO xxdl.test_object_tpe
    sl_num,
    description,
    main_val1,
    main_val2
    VALUES
    sl_num
    ,description
    ,test_type1 (test_object1(
    p_main_val1(rec).val1,
                                       p_main_val1(rec).val2,
    p_main_val1(rec).val3
    ,test_type2 (test_object2( p_main_val2(rec).val1,
                        p_main_val2(rec).val2,
                        p_main_val2(rec).val3
    END LOOP;
    commit;
    END INSERT_TEST_DATA;
    here is the anonymoys block which assigns values to the object type and pass values into the procedure:
    set serveroutput on;
    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1(1).val1 := 'testx1';
    inval1(1).val2 := 'testx2';
    inval1(1).val3 := 'testx3';
    inval2(1).val1 := 'testy1';
    inval2(1).val2 := 'testy2';
    inval2(1).val3 := 'testy3';
    CSI_PKG.INSERT_TEST_DATA(sl_num => p_sl_num,
    description => p_description,
    p_main_val1 => inval1,
    p_main_val2 => inval2
    end;
    Can anybody correct me.
    Thanks,
    Lavan

    Thanks for posting the DDL and sample code but whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    How to assign Values to nested table and pass as parameter to procedure?
    >
    Well you are doing almost everything wrong that could be done wrong.
    Here is code that works to insert data into your table (the procedure isn't even needed).
    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1.extend();
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    inval2.extend();
    inval2(1) := test_object2('testy1', 'testy2', 'testy3');
    INSERT INTO test_object_tpe
    sl_num,
    description,
    main_val1,
    main_val2
    VALUES
    (p_sl_num, p_description, inval1, inval2);
    commit;
    end;
    /See Example 5-15 Referencing a Nested Table Element in Chap 5 Using PL/SQL Collections and Records in the PL/SQL doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/collections.htm#CJABEBEA
    1. You don't even need the procedure since all it does is a simple INSERT into the table which you can do directly (see my code above)
    inval1(1).val1 := 'testx1';There is no element one (1) of 'inval1' since you haven't created any elements yet. You need to EXTEND the collection to add an element
    inval1.extend();And then there is an empty element but 'inval1' is a container for objects of type 'test_object1' not for scalars like 'val1', 'val2', and 'val3'.
    So you can't do
    inval1(1).val1 := 'testx1';You have to create an instance of 'test_object1'
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');And so on for the other collection
    You don't need the procedure (as my sample code shows) but once you populate the variables properly it will work.

  • How to get the activity instance id and process id

    Dear All,
    For my case, my boss require the workflow program processor can be runtime assigned . After research, I found the coding example like below:
    // dynamically assign a user to a role
    rtm.addRuntimeDefinedUserToRole(
                      // process instance
                      prInstance,
                      // role name
                      "Processor",
                      // user that is assigned (IUser)
                      user,
                      // user context (IGPUserContext)
                      userContext);
    // dynamically change the user assigned to a role for a particular task
    String prInstanceID = prInstance.getID();
    rtm.changeTaskProcessor(
                      // process instance ID
                      prInstanceID,
                      // activity instance ID
                      activityInstanceID,
                      // current user (IGPUserContext)
                      currentProcessorContext,
                      // new user (IGPUserContext)
                      newProcessorContext);
    But I don't know how to get the process instance ID and activity instance ID before I can apply this api in my webdynpro application.
    Any gentllement can give me an idea.
    Thank you.
    Regards
    Eric

    process =  GPProcessFactory.getDesigntimeManager().getActiveTemplate(
                                  // by specifying its ID "CCD2C3F1BED111DD9DFA005056A9416C",/
                                                 /* and the user accessing it */ userContext);
         //          retrieve the Runtime Manager
         IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
         // create an empty role assignment list
         IGPProcessRoleInstanceList roles = rtm.createProcessRoleInstanceList();
         //Initialising the input params
         IGPStructure params =GPStructureFactory.getStructure(process.getInputParameters());
         params.setAttributeValue("Name",value);
         //Starting the process
         IGPProcessInstance prInstance = rtm.startProcess(process,"Process Name","Process name",user,roles,params,user);

  • How to change the Default login script and the USER login script in Netware3.12

    I need to cut down the disk map from Neware 3.12 in Win98 client's PC.
    please tell me
    how to change the Default login script and the USER login script in
    Netware3.12 ?
    Or is there any other ways to do this thing?
    Thanks a lot!

    On 4/6/2006 [email protected] wrote:
    > how to change the Default login script and the USER login script in
    > Netware3.12 ?
    Please repost in the discontinued.forums.
    Edison Ortiz
    Novell Product Support Forum SysOp
    (No Email Support, Thanks !)

  • HOW TO CHANGE PROGRAMATICALLY LABELS OF BUTTONS AND ...

    I want to do a HTMLDB application is some languages that user choice in web page.
    I have resolve good how to change messages in pages, but I need to know how to change , labels in buttons, reports and in items.
    ¿How I can do this? Change this by program.
    Any help wellcome.
    Thanks in advanced.
    Regards everybody.

    Hi,
    Normally, to translate your entire application you would export the application using Shared Components=>Translation Services. There is documentation on how to do this:
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14303/global.htm
    You can also use Shared Components=>Manage Messages to translate individual items. If this is what you want, please let me know and I'll let you know what I did to achieve this.
    Normally, the user would select their preferred language using a browser setting. Do you intend for them to select a language on a page?
    Regards
    Andy

  • How to change the icon of JOptionPane and JFileChooser in swing

    Hi,
    Does any body know how to change the icon of JOptionPane and JFileChooser in swing.
    Please help me out in this.
    Thanx in advance.

    Try this
    import javax.swing.*;
    import java.awt.event.*;
    public class Untitled4 {
      public Untitled4() {
      public static void main(String[] args) {
        ImageIcon i = new ImageIcon("C:/TestTree/closed.gif");
        JOptionPane p = new JOptionPane();
        p.setMessage("This JOptionPane has my icon");
        p.setMessageType(JOptionPane.QUESTION_MESSAGE);
        p.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION);
        final JDialog d = p.createDialog("test");
        d.setIconImage(i.getImage());
        d.setVisible(true);
        d.setModal(true);
        if(Integer.parseInt(p.getValue().toString()) == JOptionPane.YES_OPTION) {
            System.out.println("You Clicked Yes");
    }

  • How to change value of ${eol} from \n to \r\n, writing by File Adapter

    Hi All,
    How to change value of ${eol} from \n to \r\n, while writing file through File Adapter.
    As my file is being created in Linux environment, so for new line separater, \n is used. I mounted this file directory to windows System.
    As Windows requires \r\n for new line seperator. So I need to change value of ${eol} in the Schema created for file writing.
    Can any one provide help regarding this.
    Thanks in advance

    Hi,
    When an XML payload is written to a file \n would be used as the default line separator regardless of if its windows or linux, as per the XML specification http://www.w3.org/TR/REC-xml/#sec-line-ends.
    As such, one need not worry about the line separators because, the XML file would eventually be processed by a parser which usually would be able to understand both line endings (as they are whitespace characters as far as the parser is concerned).
    If you want to convert the line terminators (for readability etc), 10.1.3.4 has a new feature - in the XML schema definition for the file adapter payload, add these two top level directives to the schema element:
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    nxsd:normalizeLineTerminators="false"
    Regards,
    Shanmu.

  • What is the difference between Instance variable and Global variable?

    Hi folks,
    Could you please explain me, "what is the difference between Instance variable and Global variable?"
    Are they really same or not?
    --Subbu                                                                                                                                                                                                                                                                                                               

    Hi flounder,
    I too know that there is no such a term GLOBAL in java.
    generally people use to say a variable which is accessible throught out the class or file has global access
    and that will be called as a global variable...
    my point is very much similar to what Looce said.
    In simple that is not a technical term, but just a causual term.
    In technically my question is, "What is the difference between a instance variable and public variable?".
    Hi looce,
    Thanks for the reply. even thats what my understanding too....in order to confirm that i raised this question..
    Your reply has given a clear answer...... thanks again.
    --Subbu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Is it possible to change theme and font size at run time?

    I want to create a project where user can change the theme and font size at run time? Is there any facility to do so in captivate 7?

    Not as far as I am aware.  A lot of the text objects (such as captions) in Captivate are actually converted to images at publish time.  So they're not able to be changed via stylesheets or variables.
    You can use Advanced Actions to hide or show images or captions with different sized text.  But not change the size of the text that is already in the caption.
    Even if you make all of the on screen text dynamic so that it's coming from some variable value, you still cannot change the font size at runtime.

  • Different Aquisition Value (APC) for group and local depreciation area?

    Hello,
    Is it possible to have different APC/acquisition value in your group and local depreciation area? We want to book the net book value as APC for local depreciation area while gross APC and accumulated depreciation are recorded in group depreciation area.
    Group Depreciation Area
    APC- 100
    Accum Dep- 20
    Local Depreciation Area
    APC-80
    I'd highly appreciate if you can give inputs.

    Hi,
    You did exactly whats required to acheive your requirement.
    There is no more further implications by removing the tick for a while and reverting after go live.
    While doing AS91, if you enter the APC value for 01 area, then that value will be automatically populated to the other dependent areas of 01 area. ( In case, if your other areas are in diff currency also, system will converts the 01 area value in to other area's curr by taking the exch rate).
    Here you can still change the APC values for the all other areas. (The other areas should have been unticked for Identical APC value check box in OABC).
    So while creating AS91, in tkaover values tab, enter APC value 80 in your 01 area and manually change the value in your group area. (REmove 80 and enter 100).
    For accum dep, in takeover values tab, enter accum dep 20 in group area only. (like OABC, in OABD also the other areas should be unticked for the identical value check box).
    This will resolve your issue.
    Thanks,
    Srinu

  • How to get the health , performance information and about the services run on devices that have connected to the system center?

    Hi All,
    I want to know how to get the health , performance information and about the services run on devices that have connected to the system center to my c# application. Also I need to know about the information of databases that have connected to system center.
    I will appreciate your feedback
    Thank you

    Hi,
    You can configure service monitor for the required service on the server
    refer below link for how to configure service monitoring
    http://www.bictt.com/blogs/bictt.php/2011/03/17/scom-monitoring-a-service-part3
    You can use SCOM SDK to connect to the scom server using c# and get required information
    http://msdn.microsoft.com/en-us/library/hh329086.aspx
    you can find the database in below registry path on management server
    HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\DatabaseName
    Regards
    sridhar v

Maybe you are looking for