Hi Mark, first of all I just wanted commend you on the great job you did on these tutorials. Every lesson has the right amount of information and is well-paced.
I've been following your examples word-by-word until Lesson 3 where you are using the scrapbook to inspect the object "p". After creating the new object, I tried to invoke the set functions, but received the error message "The method setName(String) or setMaximumBooks(int) is undefined for the type Person". I'm not sure what the problem is but maybe I forgot to include something?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After playing around with it for awhile, I think I was able to fix the problem by placing a semicolon after the closing curly braces of the Person class declaration. I'm not sure if you had to do this too?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mike. Please look in the Companion Document, on page 13. You will see the code snapshot called "Lesson 2 -- Person Class (with get and set methods)". This has the methods that were added in during lesson 2. It sounds like one or both of those methods aren't in your Person file. So just compare the code snapshot to your Person class and you should be able to see what is wrong. You can also copy and paste from the PDF into the Person file if you need to. Let me know what you find out. Thanks. Mark Dexter
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mark,
I checked over my Person.java file with yours word for word and still couldn't find any discrepancies. However, after I added a semicolon after the closing curly brace for the class declaration, the problem went away.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mike. That doesn't make much sense to me. Normally, you don't put anything after the closing "}" of a class. It sounds like you might have something else going on. If you like, you could post a copy of the source code of the Person.java file and I would be happy to look at it. Mark
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found the issue. I have more than one hard drive in my computer. Your workstation needs to be on the same drive off of which Eclipse is running. I simply moved my workspace to the same drive, and it functions just fine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Figured it out. When you set up a new project make sure you check the Use Default JRE which in my case was the new jdk1.7.0 in the JRE section. I was using the wrong JRE.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you are using a Mac - DONT select the default JRE (which is Macs OSX version), when creating the project, select 'Use and execution environment JRE' (in my case it shows JavaSE-1.6 which came with the Eclipse install) - it now works fine on my Mac..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Trevor's tip works. I installed 1.7 on my MacBook and also did the following trick, which I found when searching about how to set up Eclipse on a Mac (http://stackoverflow.com/questions/14341865/how-to-install-jre-1-7-on-mac-os-x-and-use-it-with-eclipse):
You need to tell Eclipse which JDK/JRE's you have installed and where they are located.
This is somewhat burried in the Eclipse preferences: In the Window-Menu select "Preferences". In the Preferences Tree, open the Node "Java" and select "Installed JRE's". Then click on the "Add"-Button in the Panel and select "Standard VM", "Next" and for "JRE Home" click on the "Directory"-Button and select the top level folder of the JDK you want to add.
Hi Mark, first of all I just wanted commend you on the great job you did on these tutorials. Every lesson has the right amount of information and is well-paced.
I've been following your examples word-by-word until Lesson 3 where you are using the scrapbook to inspect the object "p". After creating the new object, I tried to invoke the set functions, but received the error message "The method setName(String) or setMaximumBooks(int) is undefined for the type Person". I'm not sure what the problem is but maybe I forgot to include something?
Thanks
Hi Mark,
After playing around with it for awhile, I think I was able to fix the problem by placing a semicolon after the closing curly braces of the Person class declaration. I'm not sure if you had to do this too?
Thanks
Hi Mike. Please look in the Companion Document, on page 13. You will see the code snapshot called "Lesson 2 -- Person Class (with get and set methods)". This has the methods that were added in during lesson 2. It sounds like one or both of those methods aren't in your Person file. So just compare the code snapshot to your Person class and you should be able to see what is wrong. You can also copy and paste from the PDF into the Person file if you need to. Let me know what you find out. Thanks. Mark Dexter
Hi Mark,
I checked over my Person.java file with yours word for word and still couldn't find any discrepancies. However, after I added a semicolon after the closing curly brace for the class declaration, the problem went away.
Hi Mike. That doesn't make much sense to me. Normally, you don't put anything after the closing "}" of a class. It sounds like you might have something else going on. If you like, you could post a copy of the source code of the Person.java file and I would be happy to look at it. Mark
I've done this and I still have the same problem
I am having the same problem.
I am having the exact same problem, Lesson 3 (9:25)
Person.java is identical to that in the lesson and I have follwed this several times now with no change.
I get "The method setName(String) is undefined for the type Person" every time I inspect.
Using Eclipse Platform Version: 3.3.2
All fixed now, had other java programmes on PC.
Set Eclipse as main default for .java files and it works great now!!!!
I am having the exact same problem. Here is the code:
public class Person
{
//fields
private String name; //name of the person
private int maximumBooks; // most books person can check out
// constructors
public Person()
{
name = "unknown name";
maximumBooks = 3;
}
// methods
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;
}
}
Incidentally, I get the same error when trying the setMaximumBooks method as well.
OK, when I put the
and the the "p" after it, the inspector returns this:
But once I try putting in the methods, I get the error.
I found the issue. I have more than one hard drive in my computer. Your workstation needs to be on the same drive off of which Eclipse is running. I simply moved my workspace to the same drive, and it functions just fine.
I am having the same problem.
The method setName(String) is undefined for the type Person
Person p = new Person();
p.setName("Fred");
p
I have everything saved in the same place. I am not sure what is wrong. Here is my coding.
package org.totalbeginner.tutorial;
public class Person
{
//fields
private String name; //name of the person
private int maximumBooks; // most books person can check out
// constructors
public Person()
{
name = "unknown name";
maximumBooks = 3;
}
// methods
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;
}
}
I had to do the same here to remove the error:
" Set Eclipse as main default for .java files and it works great now"
How do you "Set Eclipse as main default for .java files" ??
Thank you!
Figured it out. When you set up a new project make sure you check the Use Default JRE which in my case was the new jdk1.7.0 in the JRE section. I was using the wrong JRE.
If you are using a Mac - DONT select the default JRE (which is Macs OSX version), when creating the project, select 'Use and execution environment JRE' (in my case it shows JavaSE-1.6 which came with the Eclipse install) - it now works fine on my Mac..
Trevor's tip works. I installed 1.7 on my MacBook and also did the following trick, which I found when searching about how to set up Eclipse on a Mac (http://stackoverflow.com/questions/14341865/how-to-install-jre-1-7-on-mac-os-x-and-use-it-with-eclipse):
You need to tell Eclipse which JDK/JRE's you have installed and where they are located.
This is somewhat burried in the Eclipse preferences: In the Window-Menu select "Preferences". In the Preferences Tree, open the Node "Java" and select "Installed JRE's". Then click on the "Add"-Button in the Panel and select "Standard VM", "Next" and for "JRE Home" click on the "Directory"-Button and select the top level folder of the JDK you want to add.
/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home