-3

I am trying to demonstrate batch apex in Eclipse Neon with Force.com IDE. Following is the code -

global class BatchApexDemoClass1 implements Database.Batchable<Sobject> {
 global Database.QueryLocator start(Database.BatchableContext bc) {
    return Database.getQueryLocator([Select LeadSource From Lead]);
 }

 global void execute(Database.BatchableContext bc, List<Lead> scope) {
    for (Lead Leads : scope) {
        Leads.LeadSource = 'Dreamforce';
    }
    update scope;
 }    

 global void finish(Database.BatchableContext bc) { 
    System.debug('Batch apex execution complete.');
 }    }

However, when I save the code, I get the following errors-

  • Save error: Class BatchApexDemoClass1 must implement the method: void Database.Batchable.finish(Database.BatchableContext)

  • Save error: Class BatchApexDemoClass1 must implement the method: void Database.Batchable.execute(Database.BatchableContext, List)

  • Offline Mode. File only saved locally, not to server

  • Save error: Class BatchApexDemoClass1 must implement the method: System.Iterable Database.Batchable.start(Database.BatchableContext)

I don't know what am I missing in the code. Please assist.

1

Your code saves correctly when creating via Setup > Apex Class. But the Offline Mode is an issue within Eclipse. A quick Google search turns up this developer guide page

By default, the Force.com IDE creates projects in offline mode. When you work in offline mode, you avoid compiling your org’s Apex code each time you save your files. If, however, you have a stable Internet connection and a small- to medium-sized code base, consider toggling your projects to online mode.

Toggle Between Offline and Online Modes Right-click your project in the Package Explorer and choose Force.com, and then select the mode in which you want to work.

  • I have already tried it. But it doesn't change anything. Also your answer would solve error - Offline Mode. File only saved locally, not to server. What about the other errors? How to resolve them? – vaibhav shetti Mar 14 '18 at 17:00
  • If you already tried, are you still getting the Offline Mode error? What happens if you try to create a new class that is not a batch? – David Cheng Mar 14 '18 at 18:41
  • it still throws error imgur.com/VCkEC6S – vaibhav shetti Mar 15 '18 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.