I have compiled it and I want to import it in another class called LoginController. The class RequestClass is basically in the same folder and right next to LoginController (so the same package, so it shouldn't need to be imported). But if I try not to import it in the LoginController class, then it simply doesn't find the RequestClass and when compiling the LoginController says error: cannot find symbol.
This is the LoginController class:
I am also guessing that this error is so ridiculous that a lot of you haven't even seen it before. So obviously the RequestClass isn't imported correctly and I just don't know how to import it in this case. I have programmed in many other languages but not that much in Java.
I know I am missing some very basic concepts here. Please, help me!
Are you using an IDE and if so did you import the class library using the IDE or just put it in the folder. I've gotten similar errors before Doing the same thing.
Joined: Dec 04, 2013
Ivan Marik wrote:Are you using an IDE and if so did you import the class library using the IDE or just put it in the folder. I've gotten similar errors before Doing the same thing.
No, I am not using an IDE precisely because I don't want to do anything that I don't understand completely. I compile first the RequestClass and then the LoginController. They are both in the same folder and yet when I compile the LoginController.java it cannot find the RequestClass.class unless I import it but then there are the other errors. I am guessing the problem lies in that the LoginController is actually a servlet! Because if I want to compile another class that uses RequestClass and is not a servlet then there is not problem.
You do not need to import classes that are in the same package (in fact, it's not even possible) - you shouldn't need the import statement at all.
If the compiler tells you it can't find the class, then that is because the current directory "." isn't in your classpath. Make sure it's included in your classpath when you compile your code. For example: