aspose file tools*
The moose likes Beginning Java and the fly likes compiler not seeing classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compiler not seeing classes" Watch "compiler not seeing classes" New topic
Author

compiler not seeing classes

Simon Knight
Greenhorn

Joined: Mar 04, 2004
Posts: 25
I'm trying to finish an assignment for Uni and am running into problems because my compiler can't seem to see a couple of classes required by my code.

To elaborate, our lecturers have provided 2 classes to help with input and output of Strings/ints and providing a date and time. With the help of these classes, I'm supposed to code a kind of quiz game.

I'm ok with the coding, but whenever I try and include methods from the 2 pre-defined classes - the compiler doesn't seem to see them, even though they're in the same folder as my code. What am I doing wrong?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Are you certain that you're specifying the class names exactly as they appear? (These are case-sensitive.)

I thought that javac always looked in the same directory for other classes (packages aside), but maybe I'm wrong. You could try adding a period to your classpath options to indicate the current directory. See the following page*...
http://faq.javaranch.com/view?HowToSetTheClasspath

* Note: In the unlikely event you are running Windows ME, then editing autoexec.bat will not work to set classpath. Instead, select Start / Programs / Accessories / System Tools / System Information. A "Microsoft Help and Support" window should appear. From the Tools menu in this window, select System Configuration Utility, then click on the Environment tab to set classpath.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Simon Knight
Greenhorn

Joined: Mar 04, 2004
Posts: 25
I'm definitely typing the class names ok.

I've tried sorting this issue in the netBeans IDE and using notepad and the command window and swapping around files/directories etc; nothing seems to work. I'm relatively new to Java and have no idea how to set classpaths and such - the link didn't do much to enlighten me I'm afraid, although I did do what it said and still no change.... I feel like I'm banging my head against a wall!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Are there package declarations at the beginning of these java files? For example, if the text starts with...

package somePackageName;

...then you'll need to save that file in a directory called "somePackageName" and set the classpath accordingly. Then if another java file outside of that package needs to use it, you'll need an import statement like...

import somePackageName.*;
Simon Knight
Greenhorn

Joined: Mar 04, 2004
Posts: 25
Ok. Thanks. Will give that a try.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: compiler not seeing classes