Reputation: 11
I have a Class written which imports some classes from JavaMail. When the application runs, it downloads the file automatically and saves it in a directory called depend. But I can't get it to import the classes from the Javamail jar I downloaded. For Example, I have:
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
At the top of the file, these classes are located in (Path to program/depend/javax.mail.jar)
Upvotes: 1
Views: 8522
Reputation: 33033
It sounds like you want to load classes over the network.
This can only be done using a ClassLoader
. It cannot be done any other way.
It can be done using RMI - but that uses a ClassLoader
internally.
Upvotes: 0
Reputation: 11841
You must ensure that the javamail.jar
file is on the classpath
.
You can do this using -classpath
arg or by setting the CLASSPATH
env var.
java -classpath
command line argCLASSPATH
environment var.Upvotes: 3