Public Static List Error

Here's why I don't use this;
or how do I have to apply a solution;

You could make the property in the BackUpConnection static:
public abstract class BackUpConnection
protected static string BacUpConnectionString
get
return @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + Path.Combine(Application.StartupPath, "BackUp.mdb");
...and access it like this:
using(OleDbConnection con = new OleDbConnection(BackUpConnection.BacUpConnectionString))
Or you can remove the static keyword from the Kesme method. As IWolbers points out you
cannot access an instance property from a static property.
Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

Similar Messages

  • List Error

    Why do i get UnSupported operation Exception for this code
    import java.util.*;
    public class ListDemo
         public static void main(String[] args)
              String[] st = {"a","b","c","d","b","b","f","g","h","rt","jk"};
              List list = Arrays.asList(st);
              dealHand(list,5);
         public static List dealHand(List deck,int n)
              int deckSize = deck.size();
              List handView = deck.subList(deckSize-n,deckSize);
              List hand = new ArrayList(handView);
              handView.clear();
              return hand;
    }Output :
    Exception in thread "main" java.lang.UnsupportedOperationException
         at java.util.AbstractList.remove(Unknown Source)
         at java.util.AbstractList$Itr.remove(Unknown Source)
         at java.util.AbstractList.removeRange(Unknown Source)
         at java.util.SubList.removeRange(Unknown Source)
         at java.util.AbstractList.clear(Unknown Source)
         at ListDemo.dealHand(ListDemo.java:16)
         at ListDemo.main(ListDemo.java:8)
    Some one Please clarify ....

    @jverd if i replace creation of list in the main function the code works fine
    import java.util.*;
    class ListDemo
         public static void main(String[] args)
              /*String[] st = {"a","b","c","d","b","b","f","g","h","rt","jk"};
              List list = Arrays.asList(st);*/
              String[] suit = new String[] {"spades", "hearts", "diamonds", "clubs"};
              String[] rank = new String[] {"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};
                         List list = new ArrayList();
                      for (int i = 0; i <suit.length; i++)
                          for (int j = 0; j <rank.length; j++)
                              list.add(rank[j] + " of " + suit);
              dealHand(list,5);
         public static List dealHand(List deck,int n)
              int deckSize = deck.size();
              List handView = deck.subList(deckSize-n,deckSize);
              List hand = new ArrayList(handView);
              handView.clear();
              return hand;
    Why is it that handview.clear() doesnt give any error when i create a list in this way .... Please clarify ?

  • Error LNK2028: unresolved token (0A00001F) "public: static class oracle....

    Hello,
    I am using MSVC C++ Express and Oracle XE. When I am building my C++ script I get the following errors:
    DbCheck.obj : error LNK2028: unresolved token (0A00001F) "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
    DbCheck.obj : error LNK2019: unresolved external symbol "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
    F:\Visual C++ Projects\DbCheck\Debug\DbCheck.exe : fatal error LNK1120: 2 unresolved externals
    I downloaded OCCI for Visual C++ 8 (Windows) Download (zip). but still get the error. I also linked oraocci10.lib and oraocci10d.lib but still nogo. I did it in the project property page under linker->input->additional dependencies. The configuration I choosed was:
    Configuration: Debug
    Platform: Win32
    Is there a way to determine what is missing or what is causing the error, does one of you know how to solve the problem?
    Thanks
    Rodger

    Could you try to create a CLR command line application and get that to run first ?
    This example here links and runs fine for me (it is a bit messy since I've been experimenting with my own mem leak problems, but it runs fine, you might want to change the select statement though)
    (The stdafx.h file only contains #pragma once, the TestRead class is there just to test mapping from std::string to System::String)
    #include "stdafx.h"
    #include <occi.h>
    using namespace System;
    using namespace std;
    using namespace oracle::occi;
    public ref class TestRead
    public:
         System::String^ GetStr(int index);
    internal:
         oracle::occi::ResultSet* m_resultSet;
    System::String^ TestRead::GetStr(int index)
         try
              return gcnew System::String(m_resultSet->getString(index).c_str());
         catch (const oracle::occi::SQLException& ex)
              throw gcnew System::Exception(gcnew System::String(ex.getMessage().c_str()));
         return "";
    int main(array<System::String ^> ^args)
    try
         oracle::occi::Environment *env = oracle::occi::Environment::createEnvironment((oracle::occi::Environment::Mode)(oracle::occi::Environment::OBJECT | oracle::occi::Environment::THREADED_MUTEXED));
    Connection *conn = env->createConnection("test","test","");
    try
    oracle::occi::Statement *stmt = conn->createStatement("Select site_addr From parcel");
    oracle::occi::ResultSet *rs = stmt->executeQuery();
         TestRead^ testread = gcnew TestRead();
         testread->m_resultSet = rs;
    //int MktId;
    string MktName;
    int rowno = 1;
    while (rs->next())
              System::String^ name = testread->GetStr(1);
    rowno++;
         // if (rowno > 100)
         //     break;
    stmt->closeResultSet(rs);
    conn->terminateStatement(stmt);
    catch (SQLException &ex)
    env->terminateConnection(conn);
    oracle::occi::Environment::terminateEnvironment(env);
    throw;//re-throw
    env->terminateConnection(conn);
    oracle::occi::Environment::terminateEnvironment(env);
    catch (SQLException &ex)
    Console::WriteLine(L"Hello World");
    return 0;
    }

  • Implementing Custom Event - non-static referencing in static context error

    Hi,
    I'm implementing a custom event, and I have problems adding my custom listeners to objects. I can't compile because I'm referencing a non-static method (my custom addListener method ) from a static context (a JFrame which contains static main).
    However, the same error occurs even if I try to add the custom listener to another class without the main function.
    Q1. Is the way I'm adding the listener wrong? Is there a way to resolve the non-static referencing error?
    Q2. From the examples online, I don't see people adding the Class name in front of addListener.
    Refering to the code below, if I remove "Data." in front of addDataUpdatelistener, I get the error:
    cannot resolve symbol method addDataUpdateListener (<anonymous DataUpdateListener>)
    I'm wondering if this is where the error is coming from.
    Below is a simplified version of my code. Thanks in advance!
    Cindy
    //dividers indicate contents are in separate source files
    //DataUpdateEvent Class
    public class DataUpdateEvent extends java.util.EventObject
         public DataUpdateEvent(Object eventSource)
              super(eventSource);
    //DataUpdateListener Interface
    public interface DataUpdateListener extends java.util.EventListener
      public void dataUpdateOccured(DataUpdateEvent event);
    //Data Class: contains data which is updated periodically. Needs to notify Display frame.
    class Data
    //do something to data
    //fire an event to notify listeners data has changed
    fireEvent(new DataUpdateEvent(this));
      private void fireEvent(DataUpdateEvent event)
           // Make a copy of the list and use this list to fire events.
           // This way listeners can be added and removed to and from
           // the original list in response to this event.
           Vector list;
           synchronized(this)
                list = (Vector)listeners.clone();
           for (int i=0; i < list.size(); i++)
                // Get the next listener and cast the object to right listener type.
               DataUpdateListener listener = (DataUpdateListener) list.elementAt(i);
               // Make a call to the method implemented by the listeners
                  // and defined in the listener interface object.
                  listener.dataUpdateOccured(event);
               System.out.println("event fired");
    public synchronized void addDataUpdateListener(DataUpdateListener listener)
         listeners.addElement(listener);
      public synchronized void removeDataUpdateListener(DataUpdateListener listener)
         listeners.removeElement(listener);
    //Display Class: creates a JFrame to display data
    public class Display extends javax.swing.JFrame
         public static void main(String args[])
              //display frame
              new Display().show();
         public Display()
         //ERROR OCCURS HERE:
         // Non-static method addDataUpdateListener (DataUpdateListener) cannot be referenced from a static context
         Data.addDataUpdateListener(new DataUpdateListener()
             public void dataUpdateOccured(DataUpdateEvent e)
                 System.out.println("Event Received!");
    //-----------------------------------------------------------

    Calling
        Data.someMethodName()is referencing a method in the Data class whose signature includes the 'static' modifier and
    might look something like this:
    class Data
        static void someMethodName() {}What you want is to add the listener to an instance of the Data class. It's just like adding
    an ActionListener to a JButton:
        JButton.addActionListener(new ActionListener()    // won't work
        JButton button = new JButton("button");           // instance of JButton
        button.addActionListener(new ActionListener()     // okay
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.swing.*;
    public class EventTest extends JFrame
        Data data;
        JLabel label;
        public EventTest()
            label = getLabel();
            data = new Data();
            // add listener to instance ('data') of Data
            data.addDataUpdateListener(new DataUpdateListener()
                public void dataUpdateOccured(DataUpdateEvent e)
                    System.out.println("Event Received!");
                    label.setText("count = " + e.getValue());
            getContentPane().add(label, "South");
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(300,200);
            setLocation(200,200);
            setVisible(true);
        private JLabel getLabel()
            label = new JLabel("  ", JLabel.CENTER);
            Dimension d = label.getPreferredSize();
            d.height = 25;
            label.setPreferredSize(d);
            return label;
        public static void main(String[] args)
            new EventTest();
    * DataUpdateEvent Class
    class DataUpdateEvent extends java.util.EventObject
        int value;
        public DataUpdateEvent(Object eventSource, int value)
            super(eventSource);
            this.value = value;
        public int getValue()
            return value;
    * DataUpdateListener Interface
    interface DataUpdateListener extends java.util.EventListener
        public void dataUpdateOccured(DataUpdateEvent event);
    * Data Class: contains data which is updated periodically.
    * Needs to notify Display frame.
    class Data
        Vector listeners;
        int count;
        public Data()
            listeners = new Vector();
            count = 0;
            new Thread(runner).start();
        private void increaseCount()
            count++;
            fireEvent(new DataUpdateEvent(this, count));
        private void fireEvent(DataUpdateEvent event)
            // Make a copy of the list and use this list to fire events.
            // This way listeners can be added and removed to and from
            // the original list in response to this event.
            Vector list;
            synchronized(this)
                list = (Vector)listeners.clone();
            for (int i=0; i < list.size(); i++)
                // Get the next listener and cast the object to right listener type.
                DataUpdateListener listener = (DataUpdateListener) list.elementAt(i);
                // Make a call to the method implemented by the listeners
                // and defined in the listener interface object.
                listener.dataUpdateOccured(event);
            System.out.println("event fired");
        public synchronized void addDataUpdateListener(DataUpdateListener listener)
            listeners.addElement(listener);
        public synchronized void removeDataUpdateListener(DataUpdateListener listener)
            listeners.removeElement(listener);
        private Runnable runner = new Runnable()
            public void run()
                boolean runit = true;
                while(runit)
                    increaseCount();
                    try
                        Thread.sleep(1000);
                    catch(InterruptedException ie)
                        System.err.println("interrupt: " + ie.getMessage());
                    if(count > 100)
                        runit = false;
    }

  • Static class error

    I have a static class:
    package VO
        public class ArrayValues
            private static var instance:ArrayValues = new ArrayValues();
            // dummy values will be first replaced with English versions
            // if the user clicks "Spanish" they will be replaced with that
            private var yesNoArray:Array = new Array('1','2');
            private var utilityArray:Array = new Array('1','2');
            public function ArrayValues()
                throw Error("ArrayValues is called by its instance");
            public static function getInstance():ArrayValues
                return instance;
            public function getYesNoArray():Array
                return yesNoArray;
            public function setYesNoArray(input:Array):void
                yesNoArray = input;
    It is invoked here:
            import VO.ArrayValues;
            import VO.InputData;
            import VO.InputLabels;
            [Bindable]
            public var saveData:InputData = InputData.getInstance();
            [Bindable]
    168       public var getArrays:ArrayValues = ArrayValues.getInstance();
    It produces this error:
    Error: ArrayValues is called by its instance
        at VO::ArrayValues()[C:\FSCalc\Flex\FSCalc\src\VO\ArrayValues.as:14]
        at VO::ArrayValues$cinit()
        at global$init()[C:\FSCalc\Flex\FSCalc\src\VO\ArrayValues.as:3]
        at components::InputForm()[C:\FSCalc\Flex\FSCalc\src\components\InputForm.mxml:168]
        at FSCalc/_FSCalc_InputForm1_i()
        at FSCalc/_FSCalc_Array6_c()
    What am I doing wrong?
    PS, is it normal to take almost 10 minutes to a) go to your discussions, b) read one response to one thread and c) get back to the normal discussion?  That seems excessive to me.

    Sorry for the late reply.  I've just got back to this project after the usual "an emergency" stuff.
    Yes, I'm looking to create a singleton.  I want to pass values around without having to have monster long parameter lists for the various components.
    I based the Flex I have on a web page and noted it is similar to the java idea, but not identical based on that page.
    I want to make sure I understand the theory behind the code.
    public function ArrayValues(access:SingletonEnforcer)
         if ( access == null )
              throw Error("ArrayValues is called by its instance");
    This is the constructor for the class which has the same name as the file it is in.  A parameter is passed of the type "SingletonEnforcer" and is then tested to see if it were ever invoked.  If it were, an error is created with a string which will be written to the console.
    Next, a variable local to this class is created that will be of the type "ArrayValues" to hold the various arrays.  BTW, either this will have to be expanded or a parallel class created to hold the Spanish values.
    static private var _instance  :  ArrayValues;
    Next, the actual work horse and true "constructor" is made.  This will either allocate a new instance of the class if it doesn't already exist or instantiate it if it doesn't.  I am confused by the second class, however, when it is created the first time.  This class is included in this file?  Doesn't the file name have to match the class?

  • NULL value in static list of values???

    I'm creating a static list of values and I want to check against these values in a table with a sql query. My question is, can I have the value for one of the items be NULL? Like, is the following static list of values ok:
    STATIC2:No Status;,Hire;HIRE,Reject;REJECT,Maybe Later;LATER
    I want it so that if someone selects "No Status" in my select list, that I check my column in the table for all records that have NULL for this value. Is that possible? Or will I have to create 2 separate queries (1 for NULL, and 1 for all the other values)?

    Actually, I had tried it, but wasn't getting an expected result. I couldn't figure out if this issue was causing my error, or something else, so I posted the question asking if it was possible to do so to try and track down where my error was coming from.

  • How to call java with public static void main(String[] args) throws by jsp?

    how do i call this from jsp? <%spServicelnd temp = new spServicelnd();%> does not work because the program has a main. can i make another 2nd.java to call this spServiceInd.java then call 2nd.java by jsp? if yes, how??? The code is found below...
    import java.net.MalformedURLException;
    import java.io.IOException;
    import com.openwave.wappush.*;
    public class spServiceInd
         private final static String ppgAddress = "http://devgate2.openwave.com:9002/pap";
         private final static String[] clientAddress = {"1089478279-49372_devgate2.openwave.com/[email protected]"};
    //     private final static String[] clientAddress = {"+639209063665/[email protected]"};
         private final static String SvcIndURI = "http://devgate2.openwave.com/cgi-bin/mailbox.cgi";
         private static void printResults(PushResponse pushResponse) throws WapPushException, MalformedURLException, IOException
              System.out.println("hello cze, I'm inside printResult");
              //Read the response to find out if the Push Submission succeded.
              //1001 = "Accepted for processing"
              if (pushResponse.getResultCode() == 1001)
                   try
                        String pushID = pushResponse.getPushID();
                        SimplePush sp = new SimplePush(new java.net.URL(ppgAddress), "SampleApp", "/sampleapp");
                        StatusQueryResponse queryResponse = sp.queryStatus(pushID, null);
                        StatusQueryResult queryResult = queryResponse.getResult(0);
                        System.out.println("Message status: " + queryResult.getMessageState());
                   catch (WapPushException exception)
                        System.out.println("*** ERROR - WapPushException (" + exception.getMessage() + ")");
                   catch (MalformedURLException exception)
                        System.out.println("*** ERROR - MalformedURLException (" + exception.getMessage() + ")");
                   catch (IOException exception)
                        System.out.println("*** ERROR - IOException (" + exception.getMessage() + ")");
              else
                   System.out.println("Message failed");
                   System.out.println(pushResponse.getResultCode());
         }//printResults
         public void SubmitMsg() throws WapPushException, IOException
              System.out.println("hello cze, I'm inside SubmitMsg");          
              try
                   System.out.println("hello cze, I'm inside SubmitMsg (inside Try)");                         
                   //Instantiate a SimplePush object passing in the PPG URL,
                   //product name, and PushID suffix, which ensures that the
                   //PushID is unique.
                   SimplePush sp = new SimplePush(new java.net.URL(ppgAddress), "SampleApp", "/sampleapp");
                   //Send the Service Indication.
                   PushResponse response = sp.pushServiceIndication(clientAddress, "You have a pending Report/Request. Please logIn to IRMS", SvcIndURI, ServiceIndicationAction.signalHigh);
                   //Print the response from the PPG.
                   printResults(response);
              }//try
              catch (WapPushException exception)
                   System.out.println("*** ERROR - WapPushException (" + exception.getMessage() + ")");
              catch (IOException exception)
                   System.out.println("*** ERROR - IOException (" + exception.getMessage() + ")");
         }//SubmitMsg()
         public static void main(String[] args) throws WapPushException, IOException
              System.out.println("hello cze, I'm inside main");
              spServiceInd spsi = new spServiceInd();
              spsi.SubmitMsg();
         }//main
    }//class spServiceInd

    In general, classes with main method should be called from command prompt (that's the reason for main method). Remove the main method, put the class in a package and import the apckage in your jsp (java classes should not be in the location as jsps).
    When you import the package in jsp, then you can instantiate the class and use any of it's methods or call the statis methods directly:
    <%
    spServiceInd spsi = new spServiceInd();
    spsi.SubmitMsg();
    %>

  • Bug in rendering static list with Hierarchical Expanding template?

    Hi,
    on http://apex.oracle.com/pls/apex/f?p=23910 I prepared test case for my problem. It is static list with template Hierarchical Expanding and following structure:
    1
      1.1
        1.1.1
      1.2
        1.2.1
    2
    Entry 1.2 has condition set to never. And the problem is, as you can see, that entry 2 seems to be under entry 1.1. But really it isn't. Reason of this strange look is that in some cases, when condition for last entry in sublist is evaluted as false, there isn't generated tag </ul> closing that sublist, in this case are not closed even two sublists - under entries 1 and 1.1.
    In my real application it is more complicated, I have static list with about 80 entries (report menu) and every user sees some reports based on his position in organization structure and other conditions. And as you can imagine, this bug produces really confusing results, almost unique for every user.
    Did anybody meet this problem too? We are on ApEx 4.1.0, it is present in 4.1.1 too (as seen on apex.oracle.com)... And I think it wasn't problem in 4.0 (at least nobody noticed for few months and I believe somebody would notice that reports for one department are under reports for another one). Used theme is standard theme 2 - Builder Blue.
    Jirka

    update:
    I tried deriving the full path for the image file by viewing the source when I embedded it in an HTML region on the same page and it gives me something similar to the following URL:
    wwv_flow_file_mgr.get_file?p_security_group_id=502133210878128108&p_fname=myImage.gif
    (p.s. it is a .gif file - not sure if this should make any material difference)
    As a result, I tried embedding this into the code:
    <fo:block>
    <fo:external-graphic src="wwv_flow_file_mgr.get_file?p_security_group_id=502133210878128108&p_fname=myImage.gif)"/>
    </fo:block>
    but this time, instead of merely not rendering, when Acrobat opens, an error message appeared reported that the file was corrupted or invalid. When trying different formats, I seem to get a generic: "500 Internal Server Error".
    I'm going to try putting the image file in the server directory tree to see if that will work. I'll post later either way.

  • Non static variable error

    There may be more errors in here besides the static variable error. I made the methods static for the method call in my constructor Product(name, price). The purpose of this Class is to the the name and price of a product from user input, subtract 5.00 from the price, and return the new price. Please help!!!
    public class Product
    public Product(String name, double price)
    String product;
    price = Product.getPrice(price);
    Double.toString(price);
    //this.product = product;
    product = Product.getName(name) + Product.getPrice(price);
    public static String getName(String name)
    System.out.println("What is their name?: ");
    name = in.nextLine(); // I GET A NONSTATIC VARIABLE ERROR FOR variable "in" HERE.
    return name;
    public static double getPrice(double price)
    this.price = price;
    System.out.println("What is the price?: ");
    price = in.nextDouble();
    return price;
    public double reducePrice()
    price = price - 5.00;
    return price;
    public String getProduct()
    product = new Product(name, price);
    return product;
    Scanner in = new Scanner(System.in);
    public static String name;
    //public double price;
    }

    you not define the class member properly.
    the class member is define before the constructor as
    public class Product {
         static Scanner in = new Scanner(System.in);
         String product;
         double price;
         public static String name;
         public Product(String name, double price) {
              price = Product.getPrice(price);
              Double.toString(price);
              // this.product = product;
              product = Product.getName(name) + Product.getPrice(price);
    }

  • Non static variable errors

    I have been working on this file for 4 days now and I can't get past these errors.
    Here's the whole project:
    package toysmanager;
    public class ToysManager {
    //Method ToysManager
    public ToysManager() {
    //Method main
    public static void main(String[] args) {
    ToddlerToy Train1 = new ToddlerToy();
    ToddlerToy Train2 = new ToddlerToy();
    ToddlerToy Train3 = new ToddlerToy();
    System.out.print("This is an object of type ToysManager");
    Train1.PrintProductID();
    Train2.PrintProductID();
    Train3.PrintProductID();
    public class ToddlerToy{
    private int ProductID = 0;
    private String ProductName = "";
    private float ProductPrice = 0;
    public ToddlerToy(int id,String name, float price){
    ProductID = id;
    ProductName = name;
    ProductPrice = price;
    //Method PrintProductID
    public int PrintProductID(){
    System.out.print("This method is PrintProductID in the class ToddlerToy");
    System.out.print("Product ID is:" + ProductID);
    return ProductID;
    public String PrintProductName(){
    System.out.print("This method is PrintProductName in the class ToddlerToy");
    System.out.print("Product Name:" + ProductName);
    return ProductName;
    public float PrintProductPrice(){
    System.out.print("This method is PrintProductPrice in the class ToddlerToy");
    System.out.print("Product Price: $" + ProductPrice);
    return ProductPrice;
    And here are the errors:
    "ToysManager.java": non-static variable this cannot be referenced from a static context at line 9, column 29
    "ToysManager.java": ToddlerToy(int,java.lang.String,float) in toysmanager.ToysManager.ToddlerToy cannot be applied to () at line 9, column 29
    "ToysManager.java": non-static variable this cannot be referenced from a static context at line 10, column 29
    "ToysManager.java": ToddlerToy(int,java.lang.String,float) in toysmanager.ToysManager.ToddlerToy cannot be applied to () at line 10, column 29
    "ToysManager.java": non-static variable this cannot be referenced from a static context at line 11, column 29
    "ToysManager.java": ToddlerToy(int,java.lang.String,float) in toysmanager.ToysManager.ToddlerToy cannot be applied to () at line 11, column 29
    Any help would be appreciated as I am plainly not understanding this even with a book.

    Annie:
    Could you help me understand the original ToyManager instructions more please? Not asking you to do the work for me I just do not understand exactly what they want me to do...
    Assignment:
    After you install JCreator, write a Java program, with a single class called ToysManager. The main method should print the name of the class, for example: "This is an object of type ToysManager."
    (Hint: the process is very similar to the "Hello World!" program.)
    Please add file (.java)
    Group Portion:
    Deliverables:  two *.java files
    As a group, add a second class called ToddlerToy to your ToysManager project.
    Here are  the requirements for the ToddlerToy:
        * The class ToddlerToy is public and has a default constructor.
        * It  has  one private attribute called  ProductID (of type int).
        * It has two public  methods called  SetProductId() and PrintProductId().
        * The method SetProductId() assigns a value to the attribute ProductId. For now, the value is hard-coded.
        * The method  PrintProductId prints the value of the attribute ProductId.
        * The class ToddlerToy has no main() method.  In Java, there is only one main method for the entire program. In this case, the main method is in the ToysManager class.
    Here are the requirements for the main method of the ToysManager class:
        * Create an object called Train1 of  class  type ToddlerToy, using the default  constructor.
        * Call the methods SetProductId() and PrintProductId() to set then print the the value of ProductId.
        * The first statement  in each method should print the name of the method, for example:  "This is method <method name> in class <class name>". This should help you trace the execution of your program. Feel free to comment out the print statement.
        * On the Small Group Discussion Board, discuss your understanding of the concepts of class, object, constructor, method, and attribute.
        * Give one example of a class (giving its name, attributes, and methods)  that could be part of the shipping application.ANY help with this at all is greatly appreciated...a friend of mine found your post and used it to give me code snippets for help and I had no idea. Nearly got me in deep water...redoing the assignment but personally I find the next two assignments much easier to understand than this one. The instructions are confusing to me...can you point me in the right direction?

  • Can you override a public static method?

    Can you override a public static method?

    A static method belongs to a class, not to a particular object, because you can call them without having an object instantiated. Methods are over rided which are inherited from an object. Since Static methods (although inherited) are not bound to a particular object, are not overridden.
    Though you have a method in the subclass with the same signatures but if you try to call super.____() you will get the error
    non-static variable super cannot be referenced from a static context

  • Static variable error in main function

    Dont know why it would be doing this. It is bascially telling me that every class I call in my main function needs to be static which is crazy.
    import javax.swing.*;
    import java.awt.*;
    class Frame extends JFrame
         public Frame()
              setTitle("My Empty Frame");
              setSize(300,200);
              setLocation(10,200);
              this.show();
    public class Main extends JFrame
         public JFrame frame;
         public Main()
              frame = new JFrame();
         public static void main(String[] args)
              System.out.println("CS348 Project 1");
              frame.setVisible(true); <--------------------ERROR
    }Thanks for the help.

    The problem (basically), is that you could do the following if you felt like it:
    import javax.swing.*;
    import java.awt.*;
    class Frame extends JFrame
         public Frame()
              setTitle("My Empty Frame");
              setSize(300,200);
              setLocation(10,200);
              this.show();
    public class Main extends JFrame
         public JFrame frame;
         public Main()
              frame = new JFrame();
         public static void main(String[] args)
              Main main1 = new Main();
              Main main2 = new Main();
              Main main3 = new Main();
              //what frame is this talking about??
              frame.setVisible(true); <--------------------ERROR
    }What you would want instead is probably something like this:
    Main main1 = new Main();
    main1.getFrame().setVisible(true);This leads to a few other questions: why are you extending JFrame if you have a JFrame variable in the class? Does that class have a JFrame, or is it a JFrame? You should almost definitely go with the "have" answer.

  • Static reference error

    Hi experts,
    I have an application that launches a simple browser.
    I have this resourcheBundle containing the url string
      ResourceBundle bundle = ResourceBundle.getBundle("Init");
      String LOCAL_URL_STRING = bundle.getString("BrowseItem");The ResourceBundle.getBundle("Init") in the resource file is:
    Init=BrowseItem=file:/D:/My Web Sites/Kingdom.htmlMy problem is how can I avoid the error message that says:
    non-static variable LOCAL_URL_STRING cannot be referenced from a static contextMy main method has this code:
    public static void main(String[] args) {
        String urlString = LOCAL_URL_STRING;
        if (args.length > 0)
           urlString = args[0];
        new Browser(urlString).setVisible(true);
      }Changing the String LOCAL_URL_STRING = bundle.getString("BrowseItem"); to static would not help either.
    Please

    Kevin_Cloutier wrote:
    Regardless of whether you use the Preferences API, if you want to access class variables from the main method (which is static) you need to have an object of the class to do so.Kevin, I have replaced that constant.
    So far I have read some of the tutorials that are suggested in this thread, but I am not getting any fitting situation yet. May be I hit the wrong tutorials.
    So I am placing my code here.
    //file: Browser.java
    package browser;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*; // for the Bundle
    public class Browser extends JFrame {
      protected JEditorPane mEditorPane;
      protected JTextField mURLField;
      ResourceBundle bundle = ResourceBundle.getBundle("Init");
      String localURLStirng = bundle.getString("BrowseItem");
      public Browser(String urlString) {
        super("Simple Browser");
        createGUI(urlString);
      protected void createGUI( String urlString ) {
        Container content = getContentPane(  );
        content.setLayout(new BorderLayout(  ));
        JToolBar urlToolBar = new JToolBar(  );
        mURLField = new JTextField(urlString, 40);
        urlToolBar.add(new JLabel(""));
        urlToolBar.add(mURLField);
        //content.add(urlToolBar, BorderLayout.NORTH);
        mEditorPane = new JEditorPane(  );
        mEditorPane.setEditable(false);
        content.add(new JScrollPane(mEditorPane), BorderLayout.CENTER);
        openURL(urlString); 
        mURLField.addActionListener(new ActionListener(  ) {
          public void actionPerformed(ActionEvent ae) {
            openURL(ae.getActionCommand(  ));
        mEditorPane.addHyperlinkListener(new LinkActivator(  ));
        setSize(500, 600);
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      protected void openURL(String urlString) {
        try {
          URL url = new URL(urlString);
          mEditorPane.setPage(url);
          mURLField.setText(url.toExternalForm(  ));
        catch (Exception e) {
          System.out.println("Couldn't open " + urlString + ":" + e);
      class LinkActivator implements HyperlinkListener {
        public void hyperlinkUpdate(HyperlinkEvent he) {
          HyperlinkEvent.EventType type = he.getEventType(  );
          if (type == HyperlinkEvent.EventType.ACTIVATED)
            openURL(he.getURL(  ).toExternalForm(  ));
      public static void main(String[] args) {
        String urlString = new String(localURLStirng);
        if (args.length > 0)
           urlString = args[0];
        new Browser( urlString ).setVisible( true );
    }I need this since the Properties file deals with this link:
    BrowseItem=file:/D:/My Web Sites/Kindgdom Bible Studies Background Information/www.kingdombiblestudies.org/Revelation/rev70.htm.
    This is a local copy of the website http://www.kingdombiblestudies.org (thanks to HTTrack) which I would like to distribute as browsable articles to none-programmer students of the Word of God regardless of the church building they represent.
    Its just that I feel the need for them to browse at this site sometimes. So I gave this effort to learning Java even if I am not a programmer.
    I therefore solicit assistance for that code alone. As one that is familiar in some degree to Spiritual things, I find it sometimes necessary to use some programming technology to assist the needs of the Kingdom of God on the earth.
    I know it is not easy to stress my points so clear, but the messages of J. Preston Eby are all very real to me.
    Things like, "No Physical Heaven, No Hell, No Rapture, No Golden Street, No Physical Satan to fear, No Physical 666 and worldwide rule of the Anti-Christ, Jesus is a corporate Man of which we are part of, All Men will attain into the experience of the Glory of God in His throne, all Men will be saved and become immortal, the new creation shall also be a creator or that the Creation is Co-extensive with THE Creator" --these are entirely controversial in the CHURCH WORLD.
    --A MUST READ I must say for the Church age to see*
    I am currently dealing with coppied link of the latest writings of J. Preston Eby in the Kingdom Bible Studies Series which can be found at:
    http://www.kingdombiblestudies.org/tablecontents.htm#REVThis man gives his letters free of charge to the rest of the world and does not ask for money. And although I am in the Philippines, I am quite affected so much by his writings that I thought that it is entirely a Great hope that somehow, someone can assist him in his Revelation Series distribution to be spread all accross the globe in electronic or letter format.
    And that is why I am here learning a lot from this forum, but I believe that there is no substitute to pure relationship, and that is why I could not relate so much to the Java API (may be I am not alone).
    We humans need a better person who could impart to us the learning that we need in the aspect of our life and walk where we need them. I can not overemphasize the examples that Jesus Christ had set. But I believe I have made my points very clear. Even Jesus himself need the proper nourishing words from his physical parents to impart practical knowlege of which it isnt written that he learned it from His School Youth 101.
    Therefore I need your help. Many come into this forum asking help becuase they are stock with their deadlines on they business projects or school assignments but my coming here is different because my cause and my reason is actually concerning the things of God.
    I need help because of the Work of God.
    Can anyone help me?
    I am not a church member. I dont go to churches. I just believe in God -- I mean, "*THE GOD*". And this is the only way I know that I can contribute to the world's needs.
    I dont mean to talk metaphysics but I think I just made my points very clear.
    The real intelligent men among you can investigate to see if I am really serious about this.
    You can as well investigate if you have time, just as we always had time to investigate the API. But that is not a requirement. All it needs for you is to hear from God the TRUTH that's in your HEART. He will reveal everythig to you.
    That might sound metaphysics to some. But it is not. It may sound crazy or insane for others. But I am assured of this:
    The foolishness of God is wiser than men
    Surely one would say, this is a technical forum.
    My simple answer is:
    Yes it is. That is why I ask technical assistance.
    Please help me.

  • Static context error

    here is the code i am having issues with
    import javax.swing.JOptionPane;
         public class GreekNumberDriver{
              public static void main (String [] args) {
                   GreekNumbers Number  = new GreekNumbers ();
                   String GreekNumber = GreekNumbers.sendGreekNumber ();
                        JOptionPane.showMessageDialog(null, GreekNumber);
              }when i try and complie i get this error:
    GreekNumberDriver.java:9: non-static method sendGreekNumber() cannot be referenced from a static context
                   String GreekNumber = GreekNumbers.sendGreekNumber ();
                                                    ^here is the spot where the error is occuring in the origonal program
         public String sendGreekNumber (){
             return message;// sends main method the greek number analysis.
          }that snippet is part of a public class defined as
    public class GreekNumbers() {
    and i dont understand how it is non-static because i have never had this error before when i have used code identical to this.

    DJ-Xen wrote:
    here is the code i am having issues with
    import javax.swing.JOptionPane;
         public class GreekNumberDriver{
              public static void main (String [] args) {
                   GreekNumbers Number  = new GreekNumbers ();
                   String GreekNumber = GreekNumbers.sendGreekNumber ();
                        JOptionPane.showMessageDialog(null, GreekNumber);
              }when i try and complie i get this error:
    GreekNumberDriver.java:9: non-static method sendGreekNumber() cannot be referenced from a static context
                   String GreekNumber = GreekNumbers.sendGreekNumber ();
                                                    ^here is the spot where the error is occuring in the origonal program
         public String sendGreekNumber (){
    return message;// sends main method the greek number analysis.
    }that snippet is part of a public class defined as
    public class GreekNumbers() {
    and i dont understand how it is non-static because i have never had this error before when i have used code identical to this.This means that sendGreekNumber () is not a static method. to use it you have to do something like (new GreekNumbers()).sendGreekNumber ();

  • Static variable error

    I know that non-static variables cannot be refrenced from a static context and I see where this error is happening but I can't figure out why. It doesn't appear that I am cross referencing static and non-static variables.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    public class CookieStuff extends JFrame implements ActionListener
         private final int XSIZE = 600;
         private final int YSIZE = 300;
         private JButton myButton;
         private JButton myButton2;
         private JLabel myLabel;
         private JLabel myLabel2;
         public JTextField myTextField;
          * Constructor
         public CookieStuff(String title)
              super(title);
              setSize(XSIZE,YSIZE);
              myButton = new JButton("Bake cookies");
              myButton2= new JButton("Eat cookies");
              myLabel = new JLabel("Number of cookies left: ");
              myLabel2= new JLabel("Enter # of cookies and select a button");
              myTextField = new JTextField(5);
              myButton.addActionListener(this);
              myButton2.addActionListener(this);
              add(myButton,BorderLayout.NORTH);
              add(myButton2,BorderLayout.SOUTH);
              add(myLabel,BorderLayout.WEST);
              add(myLabel2,BorderLayout.EAST);
              add(myTextField,BorderLayout.CENTER);
         public static void welcomeStuff()
              JOptionPane.showMessageDialog(null,"Welcome to grandma's cookie jar..");
         public void actionPerformed(ActionEvent ev)
             Object source = ev.getSource();
             if(source == myButton)
                   if(CookieJar.bake() > CookieJar.COOKIES_ALLOWED)
                        JOptionPane.showMessageDialog(this, "Grandma's jar is too small for that many cookies");
                   else
                        JOptionPane.showMessageDialog(this, CookieJar.bake());
                        myLabel.setText("Number of cookies left: " + (CookieJar.bake()));
              else
                   if(CookieJar.eat() < 0)
                        JOptionPane.showMessageDialog(this, "There are not enough cookies in the jar fatso");
                   else
                        JOptionPane.showMessageDialog(this, CookieJar.eat());
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    public class CookieJar
        public static final int COOKIES_ALLOWED = 40;
        public int numOfCookies;
        public int cookieCount;
        public CookieJar()
              cookieCount = numOfCookies;
              numOfCookies++;
         public int eat()
              int numOfCookies = 0;
              numOfCookies = (numOfCookies - Integer.parseInt(CookieStuff.myTextField.getText()));
              return numOfCookies;
         public int bake()
              int numOfCookies = 0;
              numOfCookies = (numOfCookies + Integer.parseInt(CookieStuff.myTextField.getText()));
              return numOfCookies;
    }The last 2 methods eat( ) and bake( ) are giving the errors. Thanks.

    C:\Documents and Settings\Travis Mandrell\Desktop\DePaul\CSC212\hw8\CookieStuff.java:49: non-static method bake() cannot be referenced from a static context
                   if(CookieJar.bake() > CookieJar.COOKIES_ALLOWED)
    ^
    C:\Documents and Settings\Travis Mandrell\Desktop\DePaul\CSC212\hw8\CookieStuff.java:55: non-static method bake() cannot be referenced from a static context
                        JOptionPane.showMessageDialog(this, CookieJar.bake());
    ^
    C:\Documents and Settings\Travis Mandrell\Desktop\DePaul\CSC212\hw8\CookieStuff.java:56: non-static method bake() cannot be referenced from a static context
                        myLabel.setText("Number of cookies left: " + (CookieJar.bake()));
    ^
    C:\Documents and Settings\Travis Mandrell\Desktop\DePaul\CSC212\hw8\CookieStuff.java:62: non-static method eat() cannot be referenced from a static context
                   if(CookieJar.eat() < 0)
    ^
    C:\Documents and Settings\Travis Mandrell\Desktop\DePaul\CSC212\hw8\CookieStuff.java:68: non-static method eat() cannot be referenced from a static context
    JOptionPane.showMessageDialog(this, CookieJar.eat());
    ^
    .\CookieJar.java:21: non-static variable myTextField cannot be referenced from a static context
              numOfCookies = (numOfCookies - Integer.parseInt(CookieStuff.myTextField.getText()));
    ^
    .\CookieJar.java:28: non-static variable myTextField cannot be referenced from a static context
              numOfCookies = (numOfCookies + Integer.parseInt(CookieStuff.myTextField.getText()));
    ^
    7 errors

Maybe you are looking for

  • 7.62 to 7.7 standalone upgrade says it worked, but it broke iTunes :(

    there sure seems to be an awful variety and quantity of complaints with this last release sigh... ok, probably the only time I've failed to check these boards, macintouch, etc. before I installed something, and I am at a loss as to how this 7.7 versi

  • Cannot see images occassionally: "Out of memory"

    Hi, I love Lightroom, but have the problem that is really interfering with my work. When I look at a larger collection of images (100+), every now and then the image area will be greyed out, and it will say 'Out Of Memory' in red (upside down and bac

  • Not able to add Select Supported Document Types

    Hi I am new to Oracle B2B. Going through the steps given in the tutorial http://download.oracle.com/docs/cd/E14571_01/integration.1111/e10229/b2b_tps.htm#BABGAJDE Completed till 5.3 - Task 2 (Add a User in the Oracle B2B Interface) And the Next thing

  • Http listener to port 8087, can't edit Database_homepage.url to fix link

    Installing Oracle XE on windows, I've used the instructions in the User Guide at "Changing the Listener Port Number for HTTP Connection Requests" to have the http listener run on port 8087. The last and optional step is to edit the file Database_home

  • Same Code In 2 Different Pages Behaves Differently In Each

    I have a series of three pages such that each, when submitted, calls the next one.  The first page calls the second one correctly, but the second one calls only itself.  Both are using the same code. The form code for the first page is: <form name="f