|
Re: New Mac Eclipse user [message #1480049 is a reply to message #1480035] |
Wed, 19 November 2014 23:44 |
|
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 #1690052 is a reply to message #1689906] |
Tue, 24 March 2015 20:50 |
Navy Flyer 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:20The "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!
|
|
|
Re: New Mac Eclipse user [message #1690187 is a reply to message #1689980] |
Wed, 25 March 2015 15:20 |
Eric Rizzo Messages: 3070 Registered: July 2009 |
Senior Member |
|
|
Luis Fuentes wrote on Tue, 24 March 2015 19:54from 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.
|
|
|
Powered by
FUDForum. Page generated in 0.04808 seconds