Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

non-static method within static context Question

Status
Not open for further replies.

mfalomir

Technical User
Feb 6, 2003
78
MX
How can I solve this error, Im kinda confused :) or what is telling me ?

non-static method selectRoute(java.lang.String[]) cannot be referenced from a static context

Thanks in advanced
 
1) Make the method static.
2) Instantiate an instance of the relevant class and then call the method.

--------------------------------------------------
Free Database Connection Pooling Software
 
mfalomir, I would point out that sedj's advice points are an either/or choice.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Hi thanks for you help.. As you suggested I just instantiated and instance (sounds redundant :) ) and it solved the problem :)

Thanks!
 
Just an add on here...

When I first started out with Java I got that error too many times to count. I would simply cover it up by either instantiating locally or declaring my calling method static without fully understanding what was going on.

Needless to say that led to unexpected troubles later on. In short, it is definitely worth your time(it won't take that long) to verse yourself in just what static and instance variables and methods are and how they are properly used.

I promise you'll never see that error again in your code after you do!

Cheers!

 
Hi DaWickedRebel , thanks for your advice :) I appreciate it.

Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top