File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class calling Class

 
Joel Cochran
Ranch Hand
Posts: 301
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Art Metzer
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 301
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 301
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding a dot to your classpath to get whatever directory that you are sitting in added to the classpath.
classpath= .;%classpath%
 
Joel Cochran
Ranch Hand
Posts: 301
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic