Changing a variable in adapter class

Hi,
I've deployed hello world application and I see that there was a variable like "message". And this was defined in EPN assembly file as instance-propery.
    <wlevs:adapter id="helloworldAdapter" class="com.bea.wlevs.adapter.example.helloworld.HelloWorldAdapter" >
            <wlevs:instance-property name="message" value="HelloWorld - the current time is:"/>
    </wlevs:adapter>HelloWorld application works now.
I want to change value of message variable from out of application. I could this wishes via wlevs.Admin but I am not:
java -jar wlevsadmin.jar -url service:jmx:msarmi://localhost:9002/jndi/jmxconnector -username wlevs -password xxx GET -pretty -mbean com.bea.wlevs:Name=helloworldAdapter,Type=Adapter,Application=fuat_deneme
MBeanName: "com.bea.wlevs:Name=helloworldAdapter,Type=Adapter,Application=fuat_deneme"
     InstanceProperties:
     message = HelloWorld - the current time is:
     Name: helloworldAdapter
     NotificationInfo: [Ljavax.management.MBeanNotificationInfo;@2b20bf2c
     ObjectName: com.bea.wlevs:Name=helloworldAdapter,Type=Adapter,Application=fuat_deneme
     PlaybackConfiguration:
     PlayingBack: false
     Provider:
     RecordConfiguration:
     RecordPlayback: com.bea.wlevs:Name=helloworldAdapter,Type=RecordPlayback,Application=fuat_deneme
     Recording: false
     StageClassName: com.bea.wlevs.adapter.example.helloworld.HelloWorldAdapter
     Type: AdapterOK. When I want to change :
java -jar wlevsadmin.jar -url service:jmx:msarmi://localhost:9002/jndi/jmxconnector -username wlevs -password xxx SET -mbean com.bea.wlevs:Name=helloworldAdapter,Type=Adapter,Application=fuat_deneme -property message "aaa"
Property Name and value not valid for the MBean. Value aaa for parameter[message].java.lang.IllegalArgumentException: Unable to find the attribute: message in the attribute list of the class: null
Description:
Sets property values for Administration MBeans or Local Configuration MBeans. This command cannot be used for Runtime MBeans.
Usage:
java wlevs.Admin
      [-url | -listenAddress <host-name> -listenPort <port>]
     -username <username> -password <password>
     SET {-type <mbeanType>|-mbean <objectName>} [-property <property> [<value>]]...
Where:
-type = Sets the properties for all MBeans of the specified type.
-mbean = Fully qualified object name of an MBean.
-property = The name of the property to be set.
<value> = The value to be set.
java wlevs.Admin -url service:jmx:msarmi://localhost:9002/jndi/jmxconnector -username wlevs -password wlevs SET -type Server -property StdoutSeverityLevel 64
java wlevs.Admin -url service:jmx:msarmi://localhost:9002/jndi/jmxconnector -username wlevs -password wlevs SET -mbean mydomain:Location=oamserver,Name=myserver,Type=ServerConfig -property StdoutSeverityLevel 64How can I change a variable of an adapter class in runtime?

I did your suggestion but I am getting ClassNotFound error. However I already specified that as " com.bea.wlevs.management.configuration" in MANIFEST. Also, I can import "com.bea.wlevs.management.configuration.spi.ConfigurationMBeanFactory" class in any our class.
java.lang.IllegalArgumentException: Cannot find class [com.bea.wlevs.management.configuration.spi.ConfigurationMBeanFactory]
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
     at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
     at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:139)
     at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:62)
     at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
     at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused By: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class[]] for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.bea.wlevs.management.configuration.spi.ConfigurationMBeanFactory]
     at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
     at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
     at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:139)
     at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:62)
     at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
     at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused By: java.lang.IllegalArgumentException: Cannot find class [com.bea.wlevs.management.configuration.spi.ConfigurationMBeanFactory]
     at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:233)
     at org.springframework.beans.propertyeditors.ClassArrayEditor.setAsText(ClassArrayEditor.java:66)
     at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:382)
     at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:358)
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:173)
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
     at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
     at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
     at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
     at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61)
     at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
     at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused By: java.lang.ClassNotFoundException: com.bea.wlevs.management.configuration.spi.ConfigurationMBeanFactory not found from bundle [AfterJMS_2]
     at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)
     at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
     at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:230)
     at org.springframework.beans.propertyeditors.ClassArrayEditor.setAsText(ClassArrayEditor.java:66)
     at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:382)
     at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:358)
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:173)
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
     at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1011)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
     at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
     at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:139)
     at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:62)
     at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
     at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused By: java.lang.ClassNotFoundException: com.bea.wlevs.management.configuration.spi.ConfigurationMBeanFactory
     at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
     at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
     at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
     at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:123)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:326)
     at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:231)
     at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1193)
     at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)
     at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
     at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:230)
     at org.springframework.beans.propertyeditors.ClassArrayEditor.setAsText(ClassArrayEditor.java:66)
     at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:382)
     at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:358)
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:173)
     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
     at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1011)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
     at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
     at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
     at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:139)
     at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:62)
     at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
     at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

Similar Messages

  • Change public variables that are used in another class to private variables

    Hi
    I have public variables in one class and I am also using them in another class the only thing is all my variables are supposed to be private. When I change then to private then I cannot use them in the other class. Please someone help me.
    Thanks
    D

    First way - make variables protected an you can access them from any class within package or from any class that extends class with variables.
    Second - make variables private and create public get/set methods for that variables for accessing they from any other class/package.(That's preferable way).
    I have public variables in one class and I am also
    using them in another class the only thing is all my
    variables are supposed to be private. When I change
    then to private then I cannot use them in the other
    class. Please someone help me.

  • Problem with final variables and inner classes (JDK1.1.8)

    When using JDK1.1.8, I came up with following:
    public class Outer
        protected final int i;
        protected Inner inner = null;
        public Outer(int value)
            i = value;
            inner = new Inner();
            inner.foo();
        protected class Inner
            public void foo()
                System.out.println(i);
    }causing this:
    Outer.java:6: Blank final variable 'i' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
    public Outer(int value)
    ^
    1 error
    With JDK 1.3 this works just fine, as it does with 1.1.8 if
    1) I don't use inner class, or
    2) I assign the value in initializer, or
    3) I leave the keyword final away.
    and none of these is actually an option for me, neither using a newer JDK, if only there is another way to solve this.
    Reasons why I am trying to do this:
    1) I can't use a newer JDK
    2) I want to be able to assign the variables value in constructor
    3) I want to prevent anyone (including myself ;)) from changing the value in other parts of the class (yes, the code above is just to give you the idea, not the whole code)
    4) I must be able to use inner classes
    So, does anyone have a suggestion how to solve this problem of mine? Or can someone say that this is a JDK 1.1.8 feature, and that I just have to live with it? In that case, sticking to solution 3 is probably the best alternative here, at least for me (and hope that no-one will change the variables value). Or is it crappy planning..?

    You cannot use a final field if you do not
    initialize it at the time of declaration. So yes,
    your design is invalid.Sorry if I am being a bit too stubborn or something. :) I am just honestly a bit puzzled, since... If I cannot use a final field in an aforementioned situation, why does following work? (JDK 1.3.1 on Linux)
    public class Outer {
            protected final String str;
            public Outer(String paramStr) {
                    str = paramStr;
                    Inner in = new Inner();
                    in.foo();
            public void foo() {
                    System.out.println("Outer.foo(): " + str);
            public static void main( String args[] ) {
                    String param = new String("This is test.");
                    Outer outer = new Outer(param);
                    outer.foo();
            protected class Inner {
                    public void foo() {
                            System.out.println("Inner.foo(): " + str);
    } producing the following:
    [1:39] % javac Outer.java
    [1:39] % java Outer
    Inner.foo(): This is test.
    Outer.foo(): This is test.
    Is this then an "undocumented feature", working even though it shouldn't work?
    However, I assume you could
    get by with eliminating the final field and simply
    passing the value directly to the Inner class's
    constructor. if not, you'll have to rethink larger
    aspects of your design.I guess this is the way it must be done.
    Jussi

  • J2ME error to get value from variable in another class

    hi,,
    i write code for a mobile application like a tour guide..
    i had create 5 class for this application, KutaBeachDictionary MIDlet class, ListMainMenu List class, ListMenuHotel List class, HotelDes01 Form class and the last Hotel class that store all information.
    the problem is, i have [choose] variable in ListMenuHotel that contain getSelectedIndex() value, i want to take [choose] value from ListMenuHotel class to [index] variable in HotelDes01, so it determine the name of hotel that will display in form.but the index always 0 although i had choosen different menu from ListMenuHotel..
    here is all code
    in MIDlet class
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.midlet.MIDlet;
    public class KutaBeachDictionary extends MIDlet {
        public KutaBeachDictionary() {
            lstMenuUtama = new ListMenuUtama(this);
            lstMenuHotel = new ListMenuHotel(this);
            htlDes1 = new HotelDes01(this);
            frmLoading = new FormLoading(this);
        public Display getDisplay() {
            return Display.getDisplay(this);
        public void exitMIDlet() {
            switchDisplayable(null, null);
            destroyApp(true);
            notifyDestroyed();
        public void startApp() {
            if (midletPaused) {
                resumeMIDlet();
            } else {
                initialize();
                startMIDlet();
            midletPaused = false;
            getDisplay().setCurrent(frmLoading);
            new Thread(frmLoading).start();
            frmLoading.done = false;
            frmLoading.gLoading.setValue(0);
        public void pauseApp() {
            midletPaused = true;
        public void destroyApp(boolean unconditional) {
        private boolean midletPaused = false;
        public ListMenuHotel lstMenuHotel;
        public ListMenuRestaurant lstMenuRestaurant;
        ListMenuUtama lstMenuUtama;
        FormAbout frmAbout;
        public HotelDes01 htlDes1;
        FormLoading frmLoading;
    }the code in ListMenuHotel
    import java.io.IOException;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.List;
    import javax.microedition.lcdui.Ticker;
    public class ListMenuHotel extends List implements CommandListener {
        Hotel objHotel = new Hotel();
        ListMenuHotel(KutaBeachDictionary run) {
            super("List Hotel", List.IMPLICIT);
            this.run = run;
            try {
                btnImage = Image.createImage("/btnImage.png");
            } catch (IOException e) {
            tickerMenu = new Ticker("Daftar Hotel di Pantai Kuta Bali");
            setTicker(tickerMenu);
            for (int i = 0; i < objHotel.namaHotels.length; i++) {
                append(objHotel.namaHotels, btnImage);
    addCommand(new Command("Select", Command.OK, 0));
    addCommand(new Command("Back", Command.BACK, 0));
    setCommandListener(this);
    public void commandAction(Command cmd, Displayable dsp) {
    if (cmd == SELECT_COMMAND) {
    choose = getSelectedIndex();
    Display.getDisplay(run).setCurrent(run.htlDes1);
    switch (cmd.getCommandType()) {
    case Command.BACK:
    Display.getDisplay(run).setCurrent(run.lstMenuUtama);
    break;
    public int getChoose() {return choose;}
    private KutaBeachDictionary run;
    private Image btnImage;
    private Ticker tickerMenu;
    private int choose;
    the code in HotelDes01 Form classimport java.io.IOException;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.ImageItem;
    public class HotelDes01 extends Form implements CommandListener {
    private KutaBeachDictionary run;
    private int index;
    private Hotel isiHotel = new Hotel();
    public HotelDes01(KutaBeachDictionary run) {
    super("Inna Kuta Hotel");
    index = run.lstMenuHotel.getChoose(); //here is the problem..the value remain 0 althought i choose another??!!
    this.run = run;
    Image imgHotel = null;
    String namaHotel = "\n" + isiHotel.namaHotels[index] + "\n";
    try {
    imgHotel = Image.createImage("/HotelImage/interface/htlDes1.png");
    } catch (IOException e) {
    append(new ImageItem(null, imgHotel, ImageItem.LAYOUT_CENTER, null));
    append(namaHotel);
    addCommand(new Command("Back", Command.BACK, 0));
    setCommandListener(this);
    public void commandAction(Command cmd, Displayable dsp) {
    switch (cmd.getCommandType()) {
    case Command.BACK:
    Display.getDisplay(run).setCurrent(run.lstMenuHotel);
    break;
    can someone fix the code,, i had tried so many ways,,but completely failure.. T_T
    Edited by: diaca on Mar 22, 2010 7:55 AM
    Edited by: diaca on Mar 22, 2010 8:01 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    hei bro,i had solved the problem :)
    the problem is , i had constructed the form of hotelDes01 each time the program starting with this code
    public class KutaBeachDictionary extends MIDlet {
        public KutaBeachDictionary() {
            //.. declaring several new object
            htlDes1 = new HotelDes01(this);
        //..another procedure like startApp, pauseApp, etc
    public HotelDes01 htlDes1;
    }i think if i declare this class in the beginning it never updated the index value
    so i delete the code above, and i declare the htlDes1 in the listMenuHotel like this:
    public class ListMenuHotel extends List implements CommandListener {
        //..several code just like before
    public void commandAction(Command cmd, Displayable dsp) {
            if (cmd == cmdSelect) {
               objHotel.setChoose(getSelectedIndex()); //i change the code like this
               showInformation();
            if (cmd == cmdBack) {
                Display.getDisplay(run).setCurrent(run.lstMenuUtama);
        public void showInformation() {
            HotelDescription htlDes1 = new HotelDescription(run); //reconstruct the object in the class ListMenuHotel
            Display.getDisplay(run).setCurrent(htlDes1); //display the object
        }so the form of hotelDes01 now always reconstruct whenever user change the election in ListMenuHotel class and now index value get updated.. :D
    thanks for trying to fix the code qnat..
    this is my coursework, so i get to finish it ASAP..

  • Using a variable to change a variable

    Hey Everyone,
    Here's the situation. I'm creating a board game which has 3
    variables, p1Move, p2Move and activePlayer.
    p1Move and p2Move store the p1 and p2 location on a game
    board. activePlayer stored who's turn it is at the moment.
    I am loading a value in from a text file which changes the
    value of move. This all works fine when i designate a player
    directly:
    p1Move = [insert variable name],
    but i want to designate dynamically based on who's turn it
    is.
    Something like this:
    _root["p"+activePlayer+"Move"] += Number(this.varAmount);
    so that flash changes the value of p1Move (or p2Move
    depending on who's turn it is) to varAmount. varAmount is the
    variable being read from the textfile.
    Hopefully that all makes sense. Basically i want flash to
    change the variable associated with the active player only.
    Any help would be greatly appreciated, LB

    well as the docs say above, if you 're-declare' those
    variables that it will 'replace' the _global instance, so i still
    don't think i'd go that route.
    now above you say the the 'activePlayer' var works 'some' of
    the time - but that the var is sent from a text file. I think that
    you might try to load the variable from the file under a different
    name, and the declare the named var in the root, for instance in
    the text file use something like:
    playerActive=1;
    then in the root timeline where you load use something like:
    loadVariables('file.txt');
    activePlayer = playerActive;
    however it's likely that this wont be consistent either
    because the file has to 'load' before the variable is instantiated
    (available) so I'd suggest using the LoadVars class to monitor the
    load and respond when it becomes available. something like:
    var lv = new LoadVars();
    lv.onLoad = function() {
    activePlayer = this.playerActive;
    lv.load('file.txt');

  • Using a variable from one class to another

    Hi !
    I've a class called ModFam (file ModFam.java) where I define a variable as
    protected Connection dbconn;
    Inside ModFam constructor I said:
    try
    String url = "jdbc:odbc:baselocal";
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    dbconn = DriverManager.getConnection(url);
    System.err.println("Connection successful");
    } ..... rest of code
    This class define a TabbedPane as follows:
    tabbedPane.addTab("Welcome",null,new Familias(),"Familias");
    As you can see it call a new instance of the Familias class (file Familias.java).
    This constructor will try to connect with the DB to populate a combo box with some data retireved from the DB.
    If I do
    Statement stmt;
    stmt = dbconn.createStatement();
    inside Familias constructor I receive the message
    Familias.java:50: cannot resolve symbol
    symbol : variable dbconn
    location: class fam.Familias
    stmt = dbconn.createStatement();
    at compile time.
    While I can�t use a variable defined as "protected" in one class of my package on another class of the same package ?
    How could I do ?
    Thanks in advance
    <jl>

    Familias doesn't have a reference to ModFam or the Connection.
    So change the constructor in Familias to be
    public class Familias {
      private ModFam modFam;
      public Familias(ModFam m) {
        modFam = m;
    // ... somewhere else in the code
    Statement stmt = modFam.dbconn.createStatement();
    }or
    public class Familias {
      private Connection dbconn;
      public Familias(Connection c) {
        dbconn = c;
    // ... somewhere else in the code
    Statement stmt = dbconn.createStatement();
    }And when you instantiate Familias it should then be
    new Familias(this) // ModFam reference
    or
    new Familias(dbconn)

  • How do I change the variable across different methods

       A tic-tac-toe board.
    public class TicTacToe
       private String[][] board;
       private static int SIZE = 3;
          Constructs an empty board.
       public TicTacToe()
          board = new String[SIZE][SIZE];
          // Fill with spaces
          for (int i = 0; i < SIZE; i++)
             for (int j = 0; j < SIZE; j++)
                board[i][j] = " ";
          Sets a field in the board. The field must be unoccupied.
          @param i the row index
          @param j the column index
          @param player the player ("x" or "o")
       public void set(int i, int j, String player)
          if (board[i][j].equals(" "))
             board[i][j] = player;
          Creates a string representation of the board, such as
          |x  o|
          |  x |
          |   o|
          @return the string representation
       public String toString()
          String r = "";
          for (int i = 0; i < SIZE; i++)
             r = r + "|";
             for (int j = 0; j < SIZE; j++)        
                r = r + board[i][j];
             r = r + "|\n";
          return r;
    //**my TicTacToeTester
    import java.util.Scanner;
       This program tests the TicTacToe class by prompting the
       user to set positions on the board and printing out the
       result.
    public class TicTacToeTester
       public static void main(String[] args)
          Scanner in = new Scanner(System.in);
          String player = "x";
          TicTacToe game = new TicTacToe();
          boolean done = false;
          while (!done)
             System.out.print(game.toString());
             System.out.print(
                   "Row for " + player + " (-1 to exit): ");
             int row = in.nextInt();
             if (row < 0) done = true;
             else
                System.out.print("Column for " + player + ": ");
                int column = in.nextInt();
                game.set(row, column, player);
                if (player.equals("x"))
                   player = "o";
                else
                   player = "x";   
    }I had a post earlier but couldn't find it, but how do I use the user input to change the variable SIZE in TicTacToe() and toString(), this is for a class project, don't really know the language yet, I know the code that does this has to be in my main method which is in my TicTacToeTester class, I know this is probably pretty easy if you can help me with the code it would be appreicated, somebody explained it to me in words but I don't really know the language yet so a few lines of code would help me more then explaining it thanks.

    Hi,
    try it that way:
    //**my TicTacToeTester
    import java.util.Scanner;
       This program tests the TicTacToe class by prompting the
       user to set positions on the board and printing out the
       result.
    public class TicTacToeTester
       public static void main(String[] args)
          Scanner in = new Scanner(System.in);
          System.out.print("Number of cols, rows: ");
          TicTacToe game = new TicTacToe(in.nextInt());
          String player = "x";
          boolean done = false;
          while (!done)
             System.out.print(game.toString());
             System.out.print(
                   "Row for " + player + " (-1 to exit): ");
             int row = in.nextInt();
             if (row < 0) done = true;
             else
                System.out.print("Column for " + player + ": ");
                int column = in.nextInt();
                game.set(row, column, player);
                if (player.equals("x"))
                   player = "o";
                else
                   player = "x";   
       A tic-tac-toe board.
    public class TicTacToe
       private String[][] board;
       private int size;
          Constructs an empty board.
       public TicTacToe(int newSize)
          this.size = newSize;
          board = new String[size][size];
          // Fill with spaces
          for (int i = 0; i < size; i++)
             for (int j = 0; j < size; j++)
                board[i][j] = " ";
          Sets a field in the board. The field must be unoccupied.
          @param i the row index
          @param j the column index
          @param player the player ("x" or "o")
       public void set(int i, int j, String player)
          if (board[i][j].equals(" "))
             board[i][j] = player;
          Creates a string representation of the board, such as
          |x  o|
          |  x |
          |   o|
          @return the string representation
       public String toString()
          String r = "";
          for (int i = 0; i < size; i++)
             r = r + "|";
             for (int j = 0; j < size; j++)        
                r = r + board[i][j];
             r = r + "|\n";
          return r;
    }L.P.

  • Getting the Adapter Class Not Found Error in the Java Manipulator

    Hi,
    I wrote a custom java manipulator for the baseline update and created a jar file for the class. This works fine in the Windows machine. All I have to do is while specifying the CLASSPATH, I entered the ./ib/newManipulator.jar; ./lib/additional_dependency.jar. When I tried to deploy the same code in the Unix environment, it fails saying the Adapter Class not found. The only difference from windows and Unix environment is that in the windows machine, in order to run the base line update, I go to the directory my_project->control->baseline_update.bat but in case of Unix environment I have a separate location where I have a shell script called run-baseline-update.sh located at /apps/bin which invokes the baseline.sh in the directory my_project/control/baseline.sh. I even tried to put the full path of the jar files e.g. /my_project/lib/newManipulator.jar; /my_project/lib/additional_dependency.jar in the class path but still the same issue. Any suggestions?

    Unix classpath needs ":" as the path separator, not ";". Changing that will make this work.
    For reference, later versions of the deployment template make this configurable, so you'd see (in environment.properties):
    # PATH_SEP_VARNAME: for platform-independence
    PATH_SEP_VARNAME=;
    # Forge needs record store libraries as well as Spring to load record store adapter configuration files
    FORGE_CLASSPATH=./config/lib/java/spring-delegate-adapter-1.0.1.jar${PATH_SEP_VARNAME}./config/lib/java/spring.jar${PATH_SEP_VARNAME}./config/lib/java/eacToolkit.jar${PATH_SEP_VARNAME}./config/script${PATH_SEP_VARNAME}.
    You can then add the following to your <forge /> definition in AppConfig.xml:
    <arg>--javaClasspath</arg>
    <arg>${FORGE_CLASSPATH}</arg>
    Hope this helps.
    Michael

  • Use ChangeWatcher to monitor change of variables

    I am trying to find an easy way to monitor the change of
    variables. Is ChangeWatch a good way to do it? I found it is used
    with binding a lot and quite complicated. Has anyone used it to
    monitor a change to variables?

    Now I have a bit of a problem. While this solution works perfect with a variable, it has an error when using a variable from ModelLocator as a class.
    BindingUtils.bindSetter(change_bindingHandler, this, "ModelLocator.getInstance().varName");
    The error is: "Property ModelLocator.getInstance().varNamenot found on MainScreen and there is no default value."
    // MainScreen.mxml code:
    <view:MainScreenClass
        xmlns:model="com.myname.model.*"
        xmlns:view="com.myname.view.*"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        width="100%" height="100%" horizontalAlign="center"
    >
    </view:MainScreenClass >
    // MainScreenClass.as:
    package org.nfcu.view
        public class MainScreenClass extends VBox {
            public function MainScreenClass() {
                super();
            public function setVariablesWatcher():void {
                BindingUtils.bindSetter(change_bindingHandler, this, "ModelLocator.getInstance().varName");

  • Help with menus and variables in different classes.

    1) how do I change variables in different classes? My situation..
    I have a few tabbed panels/planes, that ask for different user inputs. I want the last tabbed panel/plane to have the inputs on 1 plane. Is that confusing?
    Code:
            JTabbedPane tp = new JTabbedPane();
            tp.addTab ("Kitchen", new KitchenPanel());
            tp.addTab ("Living Room", new LivingRoomPanel());
            tp.addTab ("Master Bedroom", new MasterBedPanel());
            tp.addTab ("Bedroom 1", new Bedroom1Panel());
            tp.addTab ("Bedroom 2", new Bedroom2Panel());
            tp.addTab ("Misc Use", new MiscPanel());
            tp.addTab ("Totals", new TotalsPanel());not the full thing obviously, but just so u see what im working with.
    2) How do popup menus work? I have a menu (File -> About | File -> How to Contact)
    I want The File->About menu item, to prompt a dialog
    The File -> How to to prompt a dialog
    Contact Menu(Not Item) to load a webpage
    thanks again for the help, and i hope its not to confusing
    Edited by: 2point2ek on May 25, 2009 9:51 PM

    It's better to think in terms of transferring data between object, rather than between classes.
    What you need is for the tab pane objects to have a reference to some common object to which the data is to be sent. This common object might be the total pane. It's generally better design to keep the data in separate objects from the presentation (in this case the totals pane), but at this stage that's probably just going to confuse you.
    The simplest way to get this reference in is to the pane objects is as a constructor argument, which the constructor of your pane objects saves in a field. As you create each pane you pass it a reference and it stores that reference for when it needs to save data.
    Then, when you click detect the action by which the user tells the program to store the data he's entered the pane class should call a method on the central data object, passing all the data from that pane. If there's a lot of it, wrap it up in an object (typically called a "data transfer object").
    The central data object would be responsible for dealing with this data, amending totals etc.. It might delegate responsibility for updating the display to a separate total pane object.

  • Changing static variable

    hi all,
    i am in the process of developing a robotic controlling software using rxtx and java.
    in that software ther will be 16 static integer value in a class.
    in gui 16 text field will be ther and a button lebeled "send data",
    my problem is that how to change static variable from the action event of a jbutton???
    expecting some suggestion
    arnab/vu2bpw

    * Test1.java
    * Created on January 11, 2007, 5:13 PM
    * To change this template, choose Tools | Template
    Manager
    * and open the template in the editor.
    package ab;
    * @author Arnab
    class StaticTest{
    ublic static int p=5;
    public static int q=6;
    static void boom()
    System.out.println("hello from static boom");
    System.out.println(p);
    public static int getP() {
    return p;
    public class Test1 {
    /** Creates a new instance of Test1 */
    private static int r=10;
    int b=15;
    public static void main(String args[])
    System.out.print("hellow world");
    //change_static();
    StaticTest test1 = new StaticTest();
    r=test1.getP();
    StaticTest.p=b; //####error:-non static variable b
    cannot be refereanced
    from a
    static context
    static void change_static(int a)
    this is the test code of my problem.
    netbeans generating this errorYour code is confusing. You declare a variable as StaticTest, and instantiate it, but you call it test1, which is also the name of the class with main in it. However, your problem is exactly what the compiler is telling you, the non-static variable b cannot be referenced from the static context main(). Either intantiate an instance of Test1 class, or make b static.
    public class Test1{
    private static int r = 10;
    int b = 15;
    public static void main(String [] args){
        Test1 test1 = new Test1();
        r = StaticTest.getP();
        StaticTest.p = test1.b;
        System.out.println("StaticTest.p = " + StaticTest.p + " -- Test1.r = " + r);
    }~Tim

  • Sending Variables To a Class

    Hi;
    I have a package with (naturally) one class in it. A function in this class repeatedly calls another class in the same *.as file (after the package). However, on each call I need to change a number of variables. How do I do this? My background is python. In python I'd just pass values to the variables of the class. It doesn't look like I can do that here. Please advise.
    TIA,
    beno

    yes. check getter and setter functions.

  • How would I change the variables in multiple methods with the user input?

    Here is my code for a tic tac toe game I have to do for an assignment, it is currently set at the normal 3 x 3, but the teacher what the user to be albe to change these to between 3-5 before they start playing, here is my codeing
    import java.util.*;
    public class TicTacToe
    Constructs an empty board.
    private String[][] board;
    private static int ROWS = 3;
    private static int COLUMNS = 3;
    public TicTacToe()
    int size = in.nextInt();
    board = new String[ROWS][COLUMNS];
    // Fill with spaces
    for (int i = 0; i < size; i++)
    for (int j = 0; j < size; j++)
    board[i][j] = " ";
    Sets a field in the board. The field must be unoccupied.
    @param i the row index
    @param j the column index
    @param player the player ("x" or "o")
    public void set(int i, int j, String player)
    if (board[i][j].equals(" "))
    board[i][j] = player;
    Creates a string representation of the board, such as
    |x o|
    | x |
    | o|
    @return the string representation
    public String toString()
    String r = "";
    for (int i = 0; i < ROWS; i++)
    r = r + "|";
    for (int j = 0; j < COLUMNS; j++)
    r = r + board[i][j];
    r = r + "|\n";
    return r;
    I am having a problem figuring out how to change the variables ROWS , COLUMNS to the given user input, it seems easy but i can't really figure out how to do it
    thanks ahead of time

    import java.util.*;
    public class TicTacToe
    Constructs an empty board.
    private String[][] board;
    private static int ROWS = 3;
    private static int COLUMNS = 3;
    public TicTacToe()
    int size = in.nextInt();
    board = new String[ROWS][COLUMNS];
    // Fill with spaces
    for (int i = 0; i < size; i++)
    for (int j = 0; j < size; j++)
    board[j] = " ";
    Sets a field in the board. The field must be unoccupied.
    @param i the row index
    @param j the column index
    @param player the player ("x" or "o")
    public void set(int i, int j, String player)
    if (board[j].equals(" "))
    board[j] = player;
    Creates a string representation of the board, such as
    |x o|
    | x |
    | o|
    @return the string representation
    public String toString()
    String r = "";
    for (int i = 0; i < ROWS; i++)
    r = r + "|";
    for (int j = 0; j < COLUMNS; j++)
    r = r + board[j];
    r = r + "|\n";
    return r;
    }sorry for not posting code correctyl new to this forums
    Thanks for the help but let me rephrase my question, the rows and columns are the same like 3x3, 4x4 ,or 5x5,
    -when the program runs it will ask the user for what they want to set the tic tac toe at between 3 - 5.
    My question is how do I get the code
    Scanner a = new Scanner ( System.in );
    System.out.print("Enter the size of the tic tac toe box to be between 3-5 : ");
    int sizeTicTacToe = a.next();to change the variables of ROWS COLUMNS
    I just want to know of a way to make the users input of sizeTicTacToe to change the variables ROWS & COLUMNS in my toString() and TicTacToe() methods

  • How to call a variable in another class????

    if i have two classes in a package. From one class, how do i get the value of one of the variable in the other class.
    For example;
    Class A have a variable call totalNum which have a value initialise.
    Class B wan to get the value variable totalNum in class A.
    So do i go abt calling it?
    Cheers

    For example;
    Class A have a variable call totalNum which have a
    value initialise.
    Class B wan to get the value variable totalNum in
    class A.Your explanation is far from clear. Is the variable in class A a field? If yes, is it a static field? Is it declared public, private, etc.?
    If you don't understand the above questions, you should do the following:
    1) Learn the basics of the Java language from the Java Tutorial and/or from an entry-level book: http://java.sun.com/docs/books/tutorial/
    2) Post future question in the New To Java Technology forum.

  • Is there a way to reference a private variable from one class in another?

    My first class starts off by declaring variables like so:
    class tStudent {
      // declare student name, id, grades 1 & 2, and gpa
      private String fname, lname, g1, g2;
      private int id;
      private double gpa;
      // define a constructor for a new student
      tStudent () {fname=lname=g1=g2=null; id=-1; gpa=0.0;}
      // define methods for manipulating the data members.
      // readStudent: reads information for just one student
    public void read (Scanner input) {
          fname = input.next();
          lname = input.next();
          id = input.nextInt();
          g1 = input.next();
          g2 = input.next();
    }And the second class:// tStudentList: for a list of students
    class tStudentList {
      private int nStudents;
      private tStudent[] list;
      // constructor for creating student list
      tStudentList() {
          list = new tStudent[36];
          for (int i=0; i < 36; i++) list=new tStudent();
    // read the individual students into the student list
    public void read(Scanner scan) {
    nStudents=0;
    while (scan.hasNext()) {list[nStudents++].read(scan);}
    // display the list of all students - fname, lname, id, g1, g2 and gpa
    // with an appropriate header so the output matches my sample //output
    public void print() {
    Is there a way to reference the variables in the first class to use in the second? Specifically in the last section of code where I am going to print the list.

    Not without resorting to reflection hackery. If the fields are private (and are supposed to be), then that means "don't allow access to these to outsiders of this class" by design.
    So if you really meant them to be accessible, then don't use private, or provide public accessors for them.

Maybe you are looking for

  • Trying to recover Outlook 2010 contacts

    Trying to recover Outlook 2010 contacts and calendar from a HDD that cannot boot. therefore the .pst file cannot be exported. Is there a way to get the .pst and .ost files without actually running the Outlook program?

  • Experiencing frequent crashes using Safari 6.0 in ML. Below is the latest problem report.

    Process:         WebProcess [3800] Path:            /System/Library/PrivateFrameworks/WebKit2.framework/WebProcess.app/Contents/Mac OS/WebProcess Identifier:      com.apple.WebProcess Version:         8536 (8536.25) Build Info:      WebKit2-753602500

  • Create CVI DLL for HP Basic

    I was asked to create a DLL from my CVI project to use in HP/HT Basic.  How do I go about in creating one and using it in HP/HT Basic?  Is there any particular settings in CVI I need to configure to be compatible with HP/HT Basic?  Gary Z.

  • I want to install Mavericks on my new SSD before putting it in my MacBook Pro, is this possible?

    I want to install Mavericks on my new SSD before putting it in my MacBook Pro, is this possible? If so how can I do it. My MBP can run and is running Macericks now on my HDD. I do not want to transfer my file, I would prefer a fresh install on my new

  • Hide Max,Min in JFrame

    Hello, I have written an application using swings. I used JFrame. How am I to hide the maximize, minimize options at the window header? Thanks