| Author |
non-static method cannot ge referenced from a static context
|
Carrie Davis
Greenhorn
Joined: Mar 23, 2004
Posts: 4
|
|
Hi. I am hoping that someone can take a look at what I have and help me... public static TestClass get(HttpServletRequest httpservletrequest) throws TestException { String s = getSiteName(httpservletrequest); TestClass testsite = null; String as[] = getSiteList(); for(int i = 0; i < as.length; i++) if(as[i].equals(s)) testsite = get(s); if(testsite.getRealPath() == null) { String s1 = testproperties.getValue("kAssetsURL"); testsite.setRealPath(ServletContext.getRealPath(s1)); } public void setRealPath(String s) { mRealPath = s; } This is the error that I get: non-static method getRealPath cannot be referenced from a static context. [ November 17, 2004: Message edited by: Carrie Davis ]
|
 |
Jeff Bosch
Ranch Hand
Joined: Jul 30, 2003
Posts: 804
|
|
|
Your testsite.get() method will return a class, not an object (instance of a class). You can't call a non-static (instance) method for a class. You can either change the get method to a static method, or instantiate an object (using new) to access it.
|
Give a man a fish, he'll eat for one day. <br />Teach a man to fish, he'll drink all your beer.<br /> <br />Cheers,<br /> <br />Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
|
 |
 |
|
|
subject: non-static method cannot ge referenced from a static context
|
|
|