Class Path

Hi Guys,

I have a class that uses another class that I designed. until now I used an IDE like BlueJ or NetBeans that automatically looked for the classes on the same folder as the class i am writing, But now I am using an Editor called TextPad and it does not do that. The question is how can I tell the JAVA compiler where the class being used is?

Best regards

Luis

[392 byte] By [Luis_Moreiraa] at [2007-11-26 14:53:11]
# 1

> Hi Guys,

> I have a class that uses another class that I

> designed. until now I used an IDE like BlueJ or

> NetBeans that automatically looked for the classes on

> the same folder as the class i am writing, But now I

> am using an Editor called TextPad and it does not do

> that. The question is how can I tell the JAVA

> compiler where the class being used is?

> Best regards

>Luis

There are a couple ways to do this:

Set the classpath environment variable on your system to contain the root of the path where you classes can be found (where the top level package can be found).

Or, pass that information to the compiler / vm using the -cp or -classpath parameter on the command line when you run java or javac.

Or, if your working directory is the same as the directory that contains the top-level package, then the virtual machine should be able to find the classes itself.

- Adam

guitar_man_Fa at 2007-7-8 8:41:29 > top of Java-index,Java Essentials,New To Java...
# 2
Hi Adam,I am not using packages, I just have a directory called JAVA with the two classes in it. should this be enough?best regardsLuis
Luis_Moreiraa at 2007-7-8 8:41:29 > top of Java-index,Java Essentials,New To Java...
# 3
it should be, as long as your working directory is that directory... alternatively, add that directory to your classpath environment variable, OR just specify that path with the -cp switch when you execute java / javac.
guitar_man_Fa at 2007-7-8 8:41:29 > top of Java-index,Java Essentials,New To Java...
# 4
Thanks Adam,I have specified the -classpath as the working directory and that seems to work.Best regardsLuis
Luis_Moreiraa at 2007-7-8 8:41:29 > top of Java-index,Java Essentials,New To Java...