Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » New Mac Eclipse user(____ cannot be resolved to a type)
New Mac Eclipse user [message #1480035] Wed, 19 November 2014 23:30 Go to next message
Ed Wright is currently offline Ed WrightFriend
Messages: 3
Registered: November 2014
Junior Member
index.php/fa/19949/0/I'm new to eclipse and am working on a scrapbook file. When I highlight the code and hit inspect I get the error, "Person cannot be resolved to a type". In searching for solutions I come across suggestions about pointing eclipse away from Ant. I have no idea what exactly that means especially on a Mac. Can anyone shed some light on this?
Re: New Mac Eclipse user [message #1480049 is a reply to message #1480035] Wed, 19 November 2014 23:44 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4035
Registered: July 2009
Senior Member

Is "Person" the fully qualified class name? Is it in the same project, or a place configured in the Java Build Path page in that project's Properties dialog?

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: New Mac Eclipse user [message #1480111 is a reply to message #1480049] Thu, 20 November 2014 00:57 Go to previous messageGo to next message
Ed Wright is currently offline Ed WrightFriend
Messages: 3
Registered: November 2014
Junior Member
index.php/fa/19950/0/
I do believe it is the class name of this attached file. Is it in the same project? That I'm not sure of since I was under the assumption that using scrapbook did not require proper linking to a class.

[Updated on: Thu, 20 November 2014 01:11]

Report message to a moderator

Re: New Mac Eclipse user [message #1480833 is a reply to message #1480111] Thu, 20 November 2014 14:19 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3071
Registered: July 2009
Senior Member
A scrapbook has a classpath, which includes everything in the project that contains it, but no import statements by default (you can set imports for a scrapbook by right-clicking in it and choosing the Imports... option from the pop-up menu).
If Person is in the same project as your scrapbook then Person is already on the scrapbook's classpath but you still must use the fully qualified name of the classes you use in the scrapbook (unless you add them to the imports list). Ctrl+Space does work in scrapbooks, so just put your cursor on Person and use Ctrl+Space to auto-complete the full name.
Re: New Mac Eclipse user [message #1482242 is a reply to message #1480833] Fri, 21 November 2014 16:05 Go to previous messageGo to next message
Ed Wright is currently offline Ed WrightFriend
Messages: 3
Registered: November 2014
Junior Member
I tried both methods which ended up solving the error. Thanks for the feedback and patience.
Re: New Mac Eclipse user [message #1689704 is a reply to message #1480833] Tue, 24 March 2015 06:20 Go to previous messageGo to next message
Navy Flyer is currently offline Navy FlyerFriend
Messages: 2
Registered: March 2015
Junior Member
Eric Rizzo wrote on Thu, 20 November 2014 14:19
A scrapbook has a classpath, which includes everything in the project that contains it, but no import statements by default (you can set imports for a scrapbook by right-clicking in it and choosing the Imports... option from the pop-up menu).
If Person is in the same project as your scrapbook then Person is already on the scrapbook's classpath but you still must use the fully qualified name of the classes you use in the scrapbook (unless you add them to the imports list). Ctrl+Space does work in scrapbooks, so just put your cursor on Person and use Ctrl+Space to auto-complete the full name.


The "fully-qualified name" method using CTRL-SPACE worked for me. If I were to use the "Right-click on MyScrapbook.jpage in the Project view, select Import..." method, just WHAT would I be importing?? Please be more specific, with details from the next menu choices that appear. Thanks!
Re: New Mac Eclipse user [message #1689906 is a reply to message #1689704] Tue, 24 March 2015 15:52 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3071
Registered: July 2009
Senior Member
Navy Flyer wrote on Tue, 24 March 2015 06:20
The "fully-qualified name" method using CTRL-SPACE worked for me. If I were to use the "Right-click on MyScrapbook.jpage in the Project view, select Import..." method, just WHAT would I be importing?? Please be more specific, with details from the next menu choices that appear. Thanks!

Don't right-click on the scrapbook page in Project Explorer, right-click in the scrapbook editor and choose "Set Imports..."
Re: New Mac Eclipse user [message #1689980 is a reply to message #1480035] Tue, 24 March 2015 19:54 Go to previous messageGo to next message
Luis Fuentes is currently offline Luis FuentesFriend
Messages: 1
Registered: March 2015
Junior Member
from this forum (i can't put the url)


When a scrapbook page is created and a class from the same project is referenced, it results in a "_____ cannot be resolved to a type" error.

Can be duplicated by following the first three Total Beginner tutorials.

Does not seem to matter which folder the scrapbook page is created in. Will even happen if the scrapbook page is created in the same package as the classes referenced.

One workaround is to right-click on scrapbook page, select "set imports", and then add the current package using the Java Snippets Imports window.

Another workaround is to explicitly name the class, i.e. org.totalbeginner.tutorial.Person() instead of just Person().

I believe that the current project should be included by default no that neither workaround is required. I believe it worked this way in Juno.

Environment:
Java 7 update 45
Eclipse 4.3.1
Windows 7 with current updates as of 12/24/13

This was duplicated on two different computers to verify that it wasn't unique to any one computer.

If more information is needed, please email the author.
Re: New Mac Eclipse user [message #1690052 is a reply to message #1689906] Tue, 24 March 2015 20:50 Go to previous messageGo to next message
Navy Flyer is currently offline Navy FlyerFriend
Messages: 2
Registered: March 2015
Junior Member
[quote title=Eric Rizzo wrote on Tue, 24 March 2015 15:52]Navy Flyer wrote on Tue, 24 March 2015 06:20
The "fully-qualified name" method using CTRL-SPACE worked for me. If I were to use the "Right-click on MyScrapbook.jpage in the Project view, select Import..." method, just WHAT would I be importing?? Please be more specific, with details from the next menu choices that appear. Thanks!

Don't right-click on the scrapbook page in Project Explorer, right-click in the scrapbook editor and choose "Set Imports..."


OK, Eric, thanks! Following that tip, clicking on "Set Imports..." brings up the "Java Snippets Imports | Manage the Java Snippet Editor Imports for 'MyScrapbook.jpage' | Add or remove package imports for MyScrapbook.jpage" dialog window. What do I "Add" from here?

Proof . On a hunch, I chose "Add Packages", and because my package name is "org.totalbeginner.tutorial", I began typing "org.total..." in the "Select the packages to add as imports:" window. Lo, and behold, two entries began to appear, "org.totalbeginner", and "org.totalbeginner.tutorial". I first chose "org.totalbeginner", and the entry "org.totalbeginner.*" was placed in the previous dialog window. Seemed to me that would cover all the bases.

However, after editing the Scrapbook to remove the fully-qualified name for Person, the "Person cannot be resolved" error still showed up. So, I went back and added "org.totalbeginner.tutorial", deleted the other, and "org.totalbeginner.tutorial.*" was placed into the "Add or remove package imports for MyScrapbook.jpage" dialog window, instead. After saving, and cleaning, the error was fixed! Thanks very much for the tips. Q.E.D.

Wow, what an author like Dexter leaves OUT of his tutorial can sometimes cause A LOT of frustration!
Embarrassed Mad
Re: New Mac Eclipse user [message #1690187 is a reply to message #1689980] Wed, 25 March 2015 15:20 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3071
Registered: July 2009
Senior Member
Luis Fuentes wrote on Tue, 24 March 2015 19:54
from this forum (i can't put the url)

When a scrapbook page is created and a class from the same project is referenced, it results in a "_____ cannot be resolved to a type" error.

Can be duplicated by following the first three Total Beginner tutorials.

Does not seem to matter which folder the scrapbook page is created in. Will even happen if the scrapbook page is created in the same package as the classes referenced.

One workaround is to right-click on scrapbook page, select "set imports", and then add the current package using the Java Snippets Imports window.

Another workaround is to explicitly name the class, i.e. org.totalbeginner.tutorial.Person() instead of just Person().

I believe that the current project should be included by default no that neither workaround is required. I believe it worked this way in Juno.

A scrapbook behaves just like a Java class in this regard, a class that is not in any package. In Java you must either import every class you use from a different package, or use fully qualified names of classes. Otherwise the compiler wouldn't know what "Person" class you wanted.
The scrapbook does run in the context of the project it's in, but that does not removed the need to qualify which packages the classes are in. Assume the scrapbook is in the "default" pakage (ie, no package at all); if you had a Java class in no package, it too would need to import or fully qualify any classes it used from packages.

It sounds like these tutorials simply missed a step in setting up the scrapbook with appropriate imports. Contact the author and let him/her know.
Previous Topic:New Project Wizard Tasks Are Funky (w.t.f)
Next Topic:Customizing Ctrl+1 actions
Goto Forum:
  


Current Time: Sun Apr 18 00:46:48 GMT 2021

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

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

Back to the top