This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

importing Package

 
putti don
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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 test.java. when i try to compile test.java...it's giving error can't find package m. I have set the path environmental variable to c:\myjava

how to compile this program?

Thanks.
 
Rupak Khurana
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set the CLASSPATH environment variable
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java In General (Beginner).
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic