Reputation: 11592
I am using java1.6 without using any IDE.Now i want to use java Mail API for my purpose.So, i copied Mail.jar into d:\externaljar
folder.
And also i have set the classpath as set classpath=%classpath%;d:\externaljar;
my jdk installation folder is : c:\programfiles\jdk1.6
.
But i faced package javax.mail does not exist during compilation.
Please Guide me to get out of this issue?
Upvotes: 1
Views: 10541
Reputation: 691625
The jar file itself must be in the classpath, and not just the directory containing it.
And the CLASSPATH environment variable is CLASSPATH
, not classpath
. My advice would be to never use it, though. Always use the -classpath
(or -cp
) option with javac or java to pass the classpath.
Upvotes: 3
Reputation: 160170
I'd recommend against setting CLASSPATH
and instead use the -cp
flag:
javac -cp .;d:\externaljar\mail.jar whatever/package/YourClass.java
You may also use wildcarding:
javac -cp .;d:\externaljar\* whatever/package/YourClass.java
Running is the same thing, except you provide the classname with the main
method.
java -cp .;d:\externaljar\* whatever.package.YourClass
Upvotes: 3
Reputation: 114757
I prefer the -cp
option over the global CLASSPATH
environment variable:
java -cp .;d:/externaljar/mail.jar my.application.App
Upvotes: 3