0

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 :

  1. mail.jar
  2. dsn.jar
  3. imap.jar
  4. mailapi.jar
  5. pop3.jar
  6. 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 ?

1
  • 1
    Please specify full command how you call java Commented Jul 7, 2011 at 7:52

4 Answers 4

2

You need to specify each single jar separately in classpath, specifying directory with jars won't work.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes ! thank you. Though i have been setting classpath but i don't know why we put .; (dot semicolon in the end). What is the reason ?
Dot (.) -- means the current location from where you run the application. Semicolon (;) is the path separator under Windows. Colon (:) is the path separator under Linux/Unix.
@ 01es what does it actually mean here ? what if omit the dot ?
0

Wildcards can be used as part of the classpath. Pls refer here for more information.

Comments

0

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.