• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New classes not recognised in main

 
And Green
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all.

Got a new problem. I'm guessing it's basic but I'm at the point I need some help.

I'm currently writing new classes and compiling them successfully, when I try to reference the new class types in a main method (in a separate file but same directory) the main method cannot find my new classes and will not compile.

("cannot find symbol class: <classname>")

Both classes/files are in the same directory. Neither file belongs to any package.

My PATH environment variable seems to be OK, because the new classes compile OK, they just can't be used by other classes or files in the same directory.

Any ideas? (I'm imagining the answer may be quite embarassingly obvious!)
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Green wrote:I'm currently writing new classes and compiling them successfully, when I try to reference the new class types in a main method (in a separate file but same directory) the main method cannot find my new classes and will not compile.

("cannot find symbol class: <classname>")

Both classes/files are in the same directory. Neither file belongs to any package.
Any ideas? (I'm imagining the answer may be quite embarassingly obvious!)


Have you tried fixing the package issue -- putting all your code in proper packages?
 
And Green
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I have Pete unfortunately.

Thanks for posting though
 
Henry Wong
author
Marshal
Pie
Posts: 22094
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It may also help if you provided more details, such as... do you have a CLASSPATH set? How are you compiling it? And the exact output of the error messages.

Henry
 
And Green
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
It may also help if you provided more details, such as... do you have a CLASSPATH set? How are you compiling it? And the exact output of the error messages.

Henry


It was the classpath! Many thanks Henry and sorry to trouble you (and anyone else) with this.

(embarassed emoticon)
 
Henry Wong
author
Marshal
Pie
Posts: 22094
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Green wrote:
It was the classpath! Many thanks Henry and sorry to trouble you (and anyone else) with this.

(embarassed emoticon)



No problem. After all, that is what the "beginning java" forum is for... glad we were able to help.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic