ibanja
asked on
Eclipse Java--Scrapbook error: cannot be resolved to a type
Eclipse 3.2 Linux
I am learning Java and Eclipse from a tutorial called "Eclipse and Java for Total Beginners" located at http://eclipsetutorial.sourceforge.net/totalbeginner.html.
When I got to the Junit testing lesson I couldn't use my Crtl+Space (auto-completion). To fix it, I deleted a directory called Default. That fixed it, but now my Scrapbook is having the same problem.
Basically, it can't find my class.
Example:
Lines 1 and 2 are the errors I get when running "Inspect".
Attached is a snapshot of my Eclipse project tree.
Does anyone know how to get this fixed?
Thanks,
Frank
I am learning Java and Eclipse from a tutorial called "Eclipse and Java for Total Beginners" located at http://eclipsetutorial.sourceforge.net/totalbeginner.html.
When I got to the Junit testing lesson I couldn't use my Crtl+Space (auto-completion). To fix it, I deleted a directory called Default. That fixed it, but now my Scrapbook is having the same problem.
Basically, it can't find my class.
Example:
Person cannot be resolved to a type
Person cannot be resolved to a type
Person p = new Person();
p.setName("Fred");
p.toString()
Lines 1 and 2 are the errors I get when running "Inspect".
Attached is a snapshot of my Eclipse project tree.
Does anyone know how to get this fixed?
Thanks,
Frank
ASKER
Here is my Person.java file:
package org.totalbeginner.tutorial;
public class Person {
// fields
private String name;
private int maximumBooks;
// constructor
public Person()
{
name = "unknown name";
maximumBooks = 3;
}
public String getName()
{
return name;
}
public void setName(String anyName)
{
name = anyName;
}
public int getMaximumBooks() {
return maximumBooks;
}
public void setMaximumBooks(int maximumBooks) {
this.maximumBooks = maximumBooks;
}
}
And the class were the error is coming from?
ASKER
The Person class. It's the only thing I've coded so far.
how do you run it to get the error?
It says p.setName("Fred") but it is nowhere in your code...
It says p.setName("Fred") but it is nowhere in your code...
ASKER
I highlight the code in scrapbook and then run "inspect" from within eclipse. I'm pretty sure it's and Eclipse issue, because it worked before.
The class:
public void setName(String anyName)
{
name = anyName;
}
The class:
public void setName(String anyName)
{
name = anyName;
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
__geof__:
Thanks for the response. I had an emergency last week and couldn't get back to this until now.
I made a new directory called "newtotalBeginner."
Opened Eclipse and selected that as my new workspace.
Created a new project named "TotalBeginner."
When I selected "import" the choices were:
General
C/C++
CVS
Plug-in Development
Team
I choose General ==> File system
then I imported the directory of my old project.
That didn't work.
Should I be importing the whole directory? I also tried without the .metadata file, as well as just the src directory, but that didn't help.
Thanks for the response. I had an emergency last week and couldn't get back to this until now.
I made a new directory called "newtotalBeginner."
Opened Eclipse and selected that as my new workspace.
Created a new project named "TotalBeginner."
When I selected "import" the choices were:
General
C/C++
CVS
Plug-in Development
Team
I choose General ==> File system
then I imported the directory of my old project.
That didn't work.
Should I be importing the whole directory? I also tried without the .metadata file, as well as just the src directory, but that didn't help.
The one you want is called import project into workspace. I think it is under general.
ASKER
That's not working either... don't know what's going on, but looks like I need to start from scratch. That's not a big deal as there isn't much started, but I wanted to know what was happening in case it happens again.
Thanks
Thanks
ASKER
Since I can't import a whole project... How do I import a file? I tried and I am having the same problem.
You need to create a new Java project -> right click on it -> import -> general -> files
ASKER
I don't have the "File" option, just "File System" which didn't work.
ASKER
I'm writing this problem off and moving on.
Thanks for the help.
Thanks for the help.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Eventually post your code to help finding out.