I wrote a very simple class and comiled it OK. Another class was provided to me by someone else, the idea being that their class tests mine.

But I cannot compile the class that was given to me. I get error messages saying that "Class blah-blah cannot be found in Type Definition". Searching the IDE help I see that such an error message is produced when a typo has been made or the package cant be found. I made a package (which I dont think I really need anyway) and checked my typing, but still no luck. Has anyone got the foggiest where I am going wrong with this?

Who is Participating?

Improve company productivity with a Business Account.Sign Up

falterConnect With a Mentor Commented:
CLASSPATH is not the same as PATH!
PATH determines where your OS will lok for executables, if you specify them without the full path.
CLASSPATH tells the JVM where to llok for classes needed at Compile/Runtime

Can you post source code?

It will help to find an answer
What are the two classes (their names and package names)? And where did you place the two relative to your CLASSPATH (if you have one defined).

Did you try compiling from the command line?
futuremindsAuthor Commented:
One class is called EmailUser (the one I wrote) and the other is called TestEmailUser (which I was provided with). They dont really have package names, but when I tried putting a package name in each class it didnt make any difference.

Mine was written with the JDK v 1.1 and the other was provided to me as a textfile. The compilation was done from the command line. As for the CLASSPATH, is that the same as the PATH?

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

futuremindsAuthor Commented:
Hi falter:

This is the code for the class that I wrote, called EmailUser, which compiles OK:

public class EmailUser{

private String eName, cName,rName;

public EmailUser(String emName, String compName, String rlName){



public EmailUser(String fullAddress, String rlName){



static public boolean checkAddress(String fulladdress){

return fulladdress.indexOf("@")>=0 && !fulladdress.startsWith("@") && !fulladdress.endsWith("@");


public String emailName(){

return eName;


public String computer(){

return cName;


public String userName(){

return rName;


public boolean equals(EmailUser EmUser){

return this.equals(EmUser);


and this is the class that was supplied to me which when I try compiling returns error saying that Class EmailUser cannot be found in type declaration:

//import java.util.*;
import java.*;

class TestEmailUser

public static void main(String[] args)


String firstName = "d.c.ince";
String firstCompName = "";
String firstUsName = "Darrel Ince";
String secondName = "S.J.Ince";
String secondCompName = "";
String secondUsName = "Steph Ince";

//EmailUser first, second, third, fourth;

EmailUser first = new EmailUser(firstName, firstCompName, firstUsName);
EmailUser second = new EmailUser(secondName+"@"+secondCompName, secondUsName);
EmailUser third = new EmailUser(firstName, firstCompName, firstUsName);
EmailUser fourth = new EmailUser(secondName+"@"+secondCompName, secondUsName);

//Check emailName, computer and userName

  System.out.println("emailName OK1");
  System.out.println("computer OK2");
  System.out.println("userName OK3");
  System.out.println("emailName OK4");
  System.out.println("computer OK5");
  System.out.println("userName OK6");

//Check the checkAddress method

if (EmailUser.checkAddress(secondName+"@"+secondCompName))
  System.out.println("checkAddress OK7");
if (EmailUser.checkAddress(firstName+"@"+firstCompName))
  System.out.println("checkAddress OK8");
if (!EmailUser.checkAddress(firstName+firstCompName))
  System.out.println("checkAddress OK9");
if (!EmailUser.checkAddress("@"+firstName+firstCompName))
  System.out.println("checkAddress OK10");
if (!EmailUser.checkAddress(firstName+firstCompName+"@"))
  System.out.println("checkAddress OK11");

//Check the equals method, also it is another test of the constructors

if(first.equals(third))System.out.println("equals OK12");
if(second.equals(fourth))System.out.println("equals OK13");
if(!first.equals(second))System.out.println("equals OK14");
if(!third.equals(fourth))System.out.println("equals OK15");

//The code makes sure that your MSDOS window
//stays put for 10 seconds
//so you can examine your results. Don't worry about
//it yet it appears in the middle of the course

  Thread.sleep(10000); // Displays MSDOS window for 10 seconds
catch(Exception e){}


I see what you mean about CLASSPATH, but my classpath in Autoexec.bat doesnt refer to the directory where the classes are stored. Does that affect anything do you think?

For your simple case, place both files in the same directory, open the command window, change to that directory and try

javac -classpath . *.java

Make sure the .class files are created for both clases. Then

java -classpath . TestEmailUser

That should work.

By the way, the statement

import java.*;

is an invalid one (unless you are importing all classes in package "java" which is unlikely).

You should have


futuremindsAuthor Commented:
I looked at autoexec.bat file and found that my new Adobe graphics software had added a line that goes "@SET CLASSPATH ... ".

This made me suspicious and then I remembered that I had previously been able to both compile and run two other simple classes a couple of weeks ago before I installed the new Adobe software. I have no idea why it needed to make that adjustment to autoexec, so I remmed it out, rebooted, and hey presto, it worked. I left everything else as it had been, and so I didnt really need to make use of the solutions posted here. Let me know what you want to do about this.
Txs; Futureminds
well what i can say the class which yr friend has provided u n yr class  r not in the package. SO what i can suggest u can put bothe the packages in the same package n then try to compile . I hope u can get the perfect result.

futuremindsAuthor Commented:
Hi all;

I need to give the points to falter. He put a lot of effort into looking down the barrel for me.


futuremindsAuthor Commented:
Thanks falter; thanks all.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.