In this activity you will design your own class after running a test class.
First, create a new project in Jcreator called Teacher. Add a file to the project called Teacher and another file to the project called TestTeacher. Type in the code below for Teacher.java in that file and do the same for TestTeacher.java. Compile and run the program. Afterwards, design a new class of objects and test programmer. Once you compile the program, place it in the drop box for labs for this unit.
That is what one of my lab projects in my online class is. The problem with having an online class is I can't talk to the teacher whenever I need to and whenever I email him, I don't get an answer until the next day so I lose a day of work. This is what I am given for the project for the project TestTeacher.java. I have Teacher.java running right because it's not supposed to have a main method but this has me stumped. It says that on lines 4 and 7 "cannot find symbol class Teacher". I've tried somethings but nothing seems to help at all. I would like an answer but if you could please give me an explanation to what I'm doing wrong. I'm not trying to cheat, just understand how to do this stuff since this is what I want to do when I'm older.
Make sure Teacher.java and TestTeacher.java are in the same directory.
Are you using JCreator, or are you doing this on the command line with a simple text editor? If you're compiling the classes manually, then make sure that the CLASSPATH environment variable is not set (or make sure that the current directory is included in the classpath). In a command prompt window, try compiling the classes with commands like these:
javac -cp . Teacher.java
javac -cp . TestTeacher.java
And then try to run it with:
java -cp . TestTeacher
Note: the -cp . will set the classpath to the current directory "."
I feel so ignorant saying this, but how do I move them to make them in the same directory? My "NetBeanProjects" folder is in Documents and then once you open that, you get to choose between "Teacher" and "TestTeacher". They are in the same workspace though.
I suggest you forget NetBeans for the time being. Create yourself a directory and use a text editor to edit the code. Remember you will need two files open. Save them in your "java" directory, go to the command line and invoke the javac and java tools from there. I presume you know how to open the command line?
You can probably copy-and-paste the entire code from NetBeans to your text editor.