Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error #: 361 : class required, but identifier found(Details)

 
XJie Tu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Logger.java--->can make to Logger.class
DBHandle.java--->have to use Logger.class
DBHandle.java-->making....
Error at :import Logger;
Error #: 361 : class required,but identifier found

and Logger.class is deleted when DBHandle.java making
What's worry???
[ April 17, 2003: Message edited by: XJie Tu ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch XJie Tu,
what happens when you remove the line: import Logger; ??
[ April 17, 2003: Message edited by: Barry Gaunt ]
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of Java/javac are you using? I do get an error when I try something similar, but it is not the error that you state.

compiles fine,

states "'.' expected"
The reason for this is that you do not need to import classes that are in the same package. Also, by the nature of the naming, you do not need to import classes in the root package. As such, the import statement expects at least one "." to identify the package from which you are trying to import.
If your Logger class is not in the root package, you have to say something like:

I fyour Logger is in the same package as your DBHandle, you do not even need to import it.
 
XJie Tu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for Barry and Joel.
Thank you very much.
I use JBuilder.
To Barry:
When I remove the line: import Logger; ,
it say:
"DBHandler.java": Error #: 300 : class Logger not found in class DBHandler at line 6, column 12.
So I want to add the line: import Logger; .
To Joel:
It's not at root.I use "Context" to point to F:\JSPSTUDY\,but I use JBuilder to make them.The version of JDK in JBuilder is jdk1.3.1 .
The Logger.java and DBHandler.java are at the same project--JSPSTUDY of JBuilder.
When I remove the line: import Logger; , the result is what I said to Barry.
And the Logger.java can make to Logger.class,
but when I make the DBHandler,the Logger.class delete.
[ April 17, 2003: Message edited by: XJie Tu ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not need to say "import Logger;" if the classes are in the same package. In fact, "import Logger;" means "make the class Logger available from the default package"
This is worrying:
And the Logger.java can make to Logger.class,
but when I make the DBHandler,the Logger.class delete.

Do you really mean that compiling DBHandler.java causes the previously compiled output Logger.class to be removed from the disk?
I think, the best thing to do is to try and compile everything at the command line level without using the JBuilder IDE. (Without the "import Logger;" )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic