Eclipse does not automatically install the "Import" statement

I am a hardcore Noobie in Java (and Eclipse) and this is my first Java code.

I am using VMware Java SDK and I can run the Java samples that come with the SDK. In one of the code examples, I find this line:

import com.vmware.vcloud.sdk.Organization;

      

And the line that uses this class:

for (ReferenceType vdcLink : Organization 
                .getOrganizationByReference(vcloudClient, orgRef)
                .getVdcRefs())

      

This is where I understand how it is Organization

imported and used.

Now I am writing my own code in Eclipse and cannot make the "Organize" work. Eclipse does not write import

(however, Eclipse automatically writes statements import

for several other methods that I used from the same SDK)

Here's what I did:

I made sure that I import all .jar files (that come from the VMware SDK) into Eclipse in Project Properties -> Java Build Path -> Libraries

.

I also run CTRL+Shift+O

for ordering imports.

I also installed Windows > Preferences > "Save Actions"

and verified "Organize Imports"

that it orders the imports every time I save the program.

However, I just can't get it to Organization

work.

So, from the sample code (which works), I copied the following line into my code:

import com.vmware.vcloud.sdk.Organization;

      

But still it doesn't work. Needless to say, if I type Organization.

and then do CTRL + Space

(to show the autocomplete suggestions) it doesn't show any methods when it pops up.

I think it has something to do with setting the paths of the .jar file, but I'm not sure.

Thank.

UPDATE: This is the error I get when I use Organization: This error appears in the box when I move my mouse over the red dot at the far left of the line where I wrote Organization

:

Multiple Markers At this line
    -Orgnization cannot be resolved to a variable

      

+3


source to share


1 answer


So,

I got this as shown below. Not sure if this makes sense to you guys. But the explanation will be really helpful:

My example code is below:

In Eclipse it is in the folder project->src->com->vmware->vcloud->sdk->samples

AND it has this line at the top:package com.vmware.vcloud.sdk.samples;

So I move my code from project->src

to project->src->com->vmware->vcloud->sdk->samples

and add this package line to my code.



Now eclipse writes the import statement for Organization

and also eclipse shows me the available methods forOrganization.

Now,

I don't want to write my code inside the samples folder. Does it even make sense?

Thanks for the comments. I got this idea after reading your comments.

0


source







All Articles