For an specific emailing functionality, I have a HelloWorld.java class, calling objects inside javax.mail.jar and javax.activation.jar, looking like this:
//SENDEMAIL JAVA CLASS
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeBodyPart;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
public class HelloWorld{
public HelloWorld(){
setVersion(0);
}
public static void main(String[] args){
System.out.println("Hello World!");
}
public void setVersion(int aVersion){
version = aVersion;
}
public int getVersion(){
return version;
}
private int version;
}
While compiling and exporting a jar file in Eclipse is done fine, I am now compiling it through command line, using these command:
>javac -target 1.7 -source 1.7 -bootclasspath "C:\Program Files\MATLAB\R2018a\sys\java\jre\win64\jre\lib\rt.jar" -cp "javax.activation.jar;javax.mail.jar" HelloWorld.java
>jar cfe "HelloWorld.jar" HelloWorld "HelloWorld.class"
Without the import and the -cp sentences, these command line compilation worked fine, for several other classes, but when I try to import these new javax.mail.jar and javax.activation.jar, I cannot set the proper -cp command and eventually the relative location of these packages for making the compilation work retaining all the rest structure.
How should I fix the command?