This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes importing Package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "importing Package" Watch "importing Package" New topic

importing Package

putti don

Joined: Jul 28, 2005
Posts: 20
I have created a package by name "m" in a directory c:\myjava with the directory name m. I have created a file in c: directory which is importing the package m by name when i try to compile's giving error can't find package m. I have set the path environmental variable to c:\myjava

how to compile this program?

Rupak Khurana
Ranch Hand

Joined: Mar 01, 2005
Posts: 89
set the CLASSPATH environment variable

SCJP 1.5<br />SCWCD 1.4
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Moving to Java In General (Beginner).

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
As mentioned above, you need to set the CLASSPATH environment variable instead of PATH. The difference is that the operating system uses PATH to find programs it can execute from the command line. Including the Java installation directory in the PATH environment variable allows you to just type "java" and "javac" instead of the full path to these programs. On the other hand, Java itself uses the CLASSPATH variable to find classes. This means that the CLASSPATH should include the c:\myjava directory but PATH shouldn't.

I hope this helps. Please come back for futher clarifications if you need them.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: importing Package
It's not a secret anymore!