function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
agni.fireagni.fire 

compile error - packages vs classes

Hello,
I am new to Apex programming. I am having some trouble getting some apex code running.

Environment;
Eclipse 3.3
Apex Toolkit : 8.0.2002
Apex version on my dev account : 8
Salesforce.com instance : NA3

I have been looking at some of the examples available through the reference manual. I can get the triggers and the S-controls to work. I can't get any of the samples involving class declaration to work. I get compile errors. This simple example doesn't work when I compile in eclipse. I created New Apex Package.
I removed the default automatic code ,

package test{

}
and replaced with .

// This class updated the Hello field on account records that are
// passed to it.

public class MyHelloWorld {
    public static void addHelloWorld(Account[] accs)
    {
        for (Account a:accs)
        {
            if (a.Hello__c != 'World')
            {
            a.Hello__c = 'World';
            }
        }
     }
}

I have tried to build this on salesforce.com apex editor and get the error
Error: Compile Error: expecting "package", found 'public' at line 3 column 1

Can anyone tell me if I have an older version of the apex version that uses the older style ( uses packages??, instead of classes) or what I need to do to get these examples working?

Thanks. Your time is appreciated.



SuperfellSuperfell
Not everyone has been upgraded to summer 07 yet, so you might still be on an instance that uses the old package keyword.
Ron HessRon Hess
you will have to paste your code into the UI, Eclipse is not yet available for the 10.0 API.

we will release the updated Eclipse toolkit version on 8/15

until then use the App , under setup->build->code
SuperfellSuperfell
BTW, the existing eclipse plugin should continue to work fine with the summer 07 release.
Ron HessRon Hess
Right, if you have already create a package.

on the other hand if you create a new class in the app, it will have an API version of 10.0 and then you can't edit it in eclipse.

or am i over-simplifying the compatibility issue?


agni.fireagni.fire
Hello,
Thanks to everyone for the quick and helpful response,

Ron, I used the app ( pasted the code into the UI)  to compile the code and i still got the error
Error: Compile Error: expecting "package", found 'public' at line 3 column 1

As Simon says, maybe my instance isn't ready yet. I don't mind waiting another week for version 10 toolkit or the app upgrade.

Thanks
agni.fire



SuperfellSuperfell
The current toolkit should continue to work, at worse case, you will not be able to reference objects and fields that were added in 10.0 and are 10.0 only, other than that, everything should work as it did before the summer release.