Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Help with Java -issue(Java implementation of sample code online)
Help with Java -issue [message #1464507] Fri, 07 November 2014 11:35 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Eclipse Refuses to Compile Simple Program
Next Topic:E git plugin not automatically recognizing git projects
Goto Forum:
  


Current Time: Sun Jul 13 06:41:32 EDT 2025

Powered by FUDForum. Page generated in 0.03821 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top