Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 16:35 Go to next message
Kevin Moore is currently offline Kevin MooreFriend
Messages: 1
Registered: November 2014
Junior Member
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 14:27 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
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: Fri Mar 29 13:33:32 GMT 2024

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

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

Back to the top