Help with Java -issue [message #1464507] |
Fri, 07 November 2014 11:35  |
Eclipse User |
|
|
|
Hi,
I'm trying to implement a code snippet I found on the Vogella web site. The code snippet is as follows:
// From a view you get the site which allow to get the service
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
try {
handlerService.executeCommand("add.command", null);
} catch (Exception ex) {
throw new RuntimeException("add.command not found");
// Give message
}
}
When I add this code to my eclipse project, I get a compile time error on the getSite() call.
I'm fairly new to programming in Java/Eclipse and I'm confused where this function is defined.
I'm doing some online searching but haven't found a clear answer yet ans was hoping to get some ideas here.
Thanks,
kevin
|
|
|
Re: Help with Java -issue [message #1465623 is a reply to message #1464507] |
Sat, 08 November 2014 09:27  |
Eclipse User |
|
|
|
Quote:I'm confused where this function is defined.
As the compiler probably tells you, the method isn't defined in your class.
Please have a closer look at where you got this snippet from, it should've told you about the context that this snippet lives in. In particular look for any super class which your class should extend.
Anyway, not a tooling (i.e., Eclipse JDT) problem, but a matter of how you use snippets from the vogella site, so please follow-up with them, not here.
best,
Stephan
|
|
|
Powered by
FUDForum. Page generated in 0.03821 seconds