problem setting classpath of javamail?
I downloaded java mail because i wanted to run the code that had header files :
import javax.mail.*;
import javax.mail.internet.*
But even after setting the class path i am unable to run that code.
The jar files included in java mail are :
- mail.jar
- dsn.jar
- imap.jar
- mailapi.jar
- pop3.jar
- smtp.jar
I edited my classpath variable and finally it was :
C:\Program Files\Java\jdk1.7.0\lib;C:\Program Files\Java\javamail-1.开发者_运维知识库4.4\mail.jar;C:\Program Files\Java\javamail-1.4.4\lib;.;
The first jar file is in a seperate directory and the remaining jar files are in one directory.
If the class path is set wrong , then please tell the mistake. (i have taken the correct directories)
If there is no problem with the class path then what is the problem ?
You need to specify each single jar separately in classpath, specifying directory with jars won't work.
Wildcards can be used as part of the classpath. Pls refer here for more information.
You make the Java runtime aware of your JAR with the -cp
option:
java -cp E:\yourjarfile.jar com.yourpackage.YourProgram
You can do the same via the CLASSPATH
environment variable:
set CLASSPATH="E:\yourjarfile.jar;E:\yourotherjarfile.jar"
See this Windows example.
Also, this was answered before.
Let's say I have a directory "C:\Users\excont\Desktop\Send Mail" which contains all jar files & Java class.
so just follow this step. You will definitely get the result
C:\Users\excont\Desktop\Send Mail>set CLASSPATH=dsn.jar;imap.jar;mailapi.jar;pop3.jar;smtp.jar;.;
C:\Users\excont\Desktop\Send Mail>javac SendMail.java
C:\Users\excont\Desktop\Send Mail>java SendMail
Hope I could help you or anyone searching for the same.
精彩评论