aspose file tools*
The moose likes Beginning Java and the fly likes I don't understand what I'm being asked. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I don Watch "I don New topic
Author

I don't understand what I'm being asked.

Avery Jerauld
Greenhorn

Joined: Aug 15, 2011
Posts: 28

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.




Thank you!
Manoj Kumar Jain
Ranch Hand

Joined: Aug 22, 2008
Posts: 191

Hi Avery,

First you need to import the class Teacher to instantiate this class. This will resolve your problem of "can not find symbol"
so first write the import statement in the starting of the TestTeacher class.

Thanks


Do not wait to strike till the iron is hot; but make it hot by striking....
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
You need to import the Teacher class
Avery Jerauld
Greenhorn

Joined: Aug 15, 2011
Posts: 28

How would I import the class?
Manoj Kumar Jain
Ranch Hand

Joined: Aug 22, 2008
Posts: 191

import <package name>.Teacher;

if both classes are in same package then only will work

import should be the second statement after the package declaration in the class.
Avery Jerauld
Greenhorn

Joined: Aug 15, 2011
Posts: 28

Whenever I try



it says that it's an illegal start of expression. And I have no clue what you mean by package. If you're talking about the folder that the entire thing is under, and it was just Teacher, wouldn't I type



?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

Forget about importing class Teacher. You don't need to do that if both class Teacher and TestTeacher are in the same package (which they most likely are for your assignment).

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 "."

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Avery Jerauld
Greenhorn

Joined: Aug 15, 2011
Posts: 28

I'm using NetBeans IDE 7.0.1

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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Jesper is right about not needing to import anything; in fact you have been given some unhelpful advice about importing.
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I don't understand what I'm being asked.