Good thing this is the "Beginner" forum because I'm sure I'd be laughed off any other with this question. This my first attempt at using multiple classes. I have 2 classes in the same directory. The TestConWindow class instantiates the User class like so:
Except the compiler says
The User class is compiled and in the same directory. I tried adding the directory as a package but with no change. The code for the User class is as follows:
Why won't the compiler recognize the User class? I'm sure it must be simple and obvious but darned if I know what it is! ------------------ I'm a soldier in the NetScape Wars... Joel
Wait a minute, I'm trying to think of something clever to say...<p>Joel
Art Metzer
Ranch Hand
Joined: Oct 31, 2000
Posts: 241
posted
0
Hi, Joel. Yeah, you're program's simply not recognizing "User". I don't know where else to start, so I guess I'll ask you about your classpath. What is your classpath set to? And relative to your classpath, where do you have TestConWindow.java and User.java saved? Art
Joel Cochran
Ranch Hand
Joined: Mar 23, 2001
Posts: 301
posted
0
Originally posted by Art Metzer: Hi, Joel. Yeah, you're program's simply not recognizing "User". I don't know where else to start, so I guess I'll ask you about your classpath. What is your classpath set to? And relative to your classpath, where do you have TestConWindow.java and User.java saved? Art
In the CLASSPATH I have several .jar files for JDBC access. I thought that as long as I have the classes in the same directory it should work. I tried adding the directory they are in to the CLASSPATH, but no change. I'm really ------------------ I'm a soldier in the NetScape Wars... Joel
Joel Cochran
Ranch Hand
Joined: Mar 23, 2001
Posts: 301
posted
0
I just found http://www.javaranch.com/ubb/Forum33/HTML/002366.html and the -classpath worked, program compiled and worked like a charm. But what a poain, I don't want to have to do this for everything! Is there a better way??? ------------------ I'm a soldier in the NetScape Wars... Joel
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Try adding a dot to your classpath to get whatever directory that you are sitting in added to the classpath. classpath= .;%classpath%
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joel Cochran
Ranch Hand
Joined: Mar 23, 2001
Posts: 301
posted
0
Cindy, I have a batch file in my directory that sets up the classpath, would you add this statement to the batch file? ------------------ I'm a soldier in the NetScape Wars... Joel
Dave Vick
Ranch Hand
Joined: May 10, 2001
Posts: 3244
posted
0
Joel your bat file probably has something along the lines of set classpath=path1;path2; etc just edit it and add .; to it at the beggining like Cindy said. so it looks like this set classpath=.;path1;path2; etc... Then the compiler will always look in your current directory also when looking for class files. Dave